github.com/telepresenceio/telepresence/v2@v2.20.0-pro.6.0.20240517030216-236ea954e789/integration_test/itest/rm_as_root_windows.go (about) 1 package itest 2 3 import ( 4 "context" 5 "os" 6 7 "golang.org/x/sys/windows" 8 9 "github.com/telepresenceio/telepresence/v2/pkg/shellquote" 10 ) 11 12 func rmAsRoot(ctx context.Context, file string) error { 13 cwd, _ := os.Getwd() 14 // UTF16PtrFromString can only fail if the argument contains a NUL byte. That will never happen here. 15 verbPtr, _ := windows.UTF16PtrFromString("runas") 16 exePtr, _ := windows.UTF16PtrFromString("del") 17 cwdPtr, _ := windows.UTF16PtrFromString(cwd) 18 argPtr, _ := windows.UTF16PtrFromString(shellquote.ShellArgsString(append([]string{"/f", "/q"}, file))) 19 return windows.ShellExecute(0, verbPtr, exePtr, argPtr, cwdPtr, windows.SW_HIDE) 20 }