Skip to content

Commit

Permalink
fix: Commented unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
werniq committed Oct 22, 2024
1 parent 7173f7e commit 9dc854a
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions pkg/permission/windows.go
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
package permission

import (
"fmt"
"golang.org/x/sys/windows"
"os"
"strings"
"syscall"
)

func RunMeElevated() error {
verb := "runas"
exe, _ := os.Executable()
cwd, _ := os.Getwd()
args := strings.Join(os.Args[1:], " ")

verbPtr, _ := syscall.UTF16PtrFromString(verb)
exePtr, _ := syscall.UTF16PtrFromString(exe)
cwdPtr, _ := syscall.UTF16PtrFromString(cwd)
argPtr, _ := syscall.UTF16PtrFromString(args)

var showCmd int32 = 1 //SW_NORMAL

err := windows.ShellExecute(0, verbPtr, exePtr, argPtr, cwdPtr, showCmd)
if err != nil {
return fmt.Errorf("windows shell execute: %w", err)
}

return nil
}
//import (
// "fmt"
// "golang.org/x/sys/windows"
// "os"
// "strings"
// "syscall"
//)
//
//func RunMeElevated() error {
// verb := "runas"
// exe, _ := os.Executable()
// cwd, _ := os.Getwd()
// args := strings.Join(os.Args[1:], " ")
//
// verbPtr, _ := syscall.UTF16PtrFromString(verb)
// exePtr, _ := syscall.UTF16PtrFromString(exe)
// cwdPtr, _ := syscall.UTF16PtrFromString(cwd)
// argPtr, _ := syscall.UTF16PtrFromString(args)
//
// var showCmd int32 = 1 //SW_NORMAL
//
// err := windows.ShellExecute(0, verbPtr, exePtr, argPtr, cwdPtr, showCmd)
// if err != nil {
// return fmt.Errorf("windows shell execute: %w", err)
// }
//
// return nil
//}

0 comments on commit 9dc854a

Please sign in to comment.