diff --git a/.github/workflows/golang-test-windows.yml b/.github/workflows/golang-test-windows.yml index dcacffc0a..cd6a4e3d4 100644 --- a/.github/workflows/golang-test-windows.yml +++ b/.github/workflows/golang-test-windows.yml @@ -14,7 +14,7 @@ concurrency: jobs: test: - runs-on: windows-latest + runs-on: windows-2019 steps: - name: Checkout code uses: actions/checkout@v3 @@ -47,15 +47,17 @@ jobs: - name: Generate Iface Test bin run: go mod tidy + - name: Build helper + run: # run: go test -c -o ${{ github.workspace }}/iface-testing.bin.exe ./iface/ -# - name: Test -# if: ${{ always() }} -# run: | -# Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process -Force -# Import-Module PSScheduledJob -UseWindowsPowerShell -# Import-Module ".\Invoke-ScheduledTask.ps1" -# Import-Module ".\Invoke-CommandAs.ps1" -# Invoke-CommandAs -ScriptBlock { whoami } -AsSystem + - name: Test + if: ${{ always() }} + run: | + Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process -Force + Import-Module PSScheduledJob -UseWindowsPowerShell + Import-Module ".\Invoke-ScheduledTask.ps1" + Import-Module ".\Invoke-CommandAs.ps1" + Invoke-CommandAs -ScriptBlock { whoami } -AsSystem # Invoke-CommandAs -ScriptBlock { ${{ github.workspace }}/iface-testing.bin.exe } -AsSystem \ No newline at end of file diff --git a/testutil/runassystem.go b/testutil/runassystem.go new file mode 100644 index 000000000..f3859d644 --- /dev/null +++ b/testutil/runassystem.go @@ -0,0 +1,24 @@ +package main + +import ( + "fmt" + "os" + "os/exec" + + "golang.zx2c4.com/wireguard/windows/elevate" +) + +func main() { + argsWithoutProg := os.Args[1:] + op := func() error { + cmd := exec.Command(argsWithoutProg[0], argsWithoutProg[1:]...) + out, err := cmd.Output() + fmt.Println("") + fmt.Printf(string(out)) + if err != nil { + return err + } + return nil + } + fmt.Println(elevate.DoAsService("netbird", op)) +}