Skip to content

Commit d783183

Browse files
committed
Rename function uac.IsAdmin to uac.IsElevated
1 parent 902789f commit d783183

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

uac/uac.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package uac
33
import (
44
"errors"
55
"os"
6-
"os/exec"
76
"strings"
87
"syscall"
98
"time"
@@ -23,7 +22,7 @@ func PromptWithExtraArguments(messageFilePath string, maxWaitTime time.Duration,
2322
return err
2423
}
2524

26-
if IsAdmin() {
25+
if IsElevated() {
2726
err := job()
2827
message := []byte("")
2928

@@ -77,15 +76,8 @@ func PromptWithExtraArguments(messageFilePath string, maxWaitTime time.Duration,
7776
return nil
7877
}
7978

80-
func IsAdmin() bool {
81-
systemRoot := os.Getenv("SYSTEMROOT")
82-
cmd := exec.Command(systemRoot+`\system32\cacls.exe`, systemRoot+`\system32\config\system`)
83-
84-
if err := cmd.Run(); nil != err {
85-
return false
86-
}
87-
88-
return true
79+
func IsElevated() bool {
80+
return windows.GetCurrentProcessToken().IsElevated()
8981
}
9082

9183
func doPrompt(extraArguments []string) error {

0 commit comments

Comments
 (0)