mirror of
https://github.com/coreybutler/nvm-windows.git
synced 2026-01-14 07:03:17 +08:00
Add alt admin check - currently removed by tree shaking, but left for reference.
This commit is contained in:
12
src/nvm.go
12
src/nvm.go
@@ -848,7 +848,7 @@ func runElevated(command string, forceUAC ...bool) (bool, error) {
|
||||
}
|
||||
|
||||
if uac {
|
||||
log.Print(command)
|
||||
// Alternative elevation option at stackoverflow.com/questions/31558066/how-to-ask-for-administer-privileges-on-windows-with-go
|
||||
cmd := exec.Command(filepath.Join(env.root, "elevate.cmd"), command)
|
||||
var output bytes.Buffer
|
||||
var _stderr bytes.Buffer
|
||||
@@ -971,3 +971,13 @@ func setup() {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func isAdmin() bool {
|
||||
fs, err := os.Open("\\\\.\\PHYSICALDRIVE0")
|
||||
if err == nil {
|
||||
fs.Close()
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user