Skip to content

Commit

Permalink
fix run elevated powershell scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Yetenol committed Oct 10, 2022
1 parent f4c7b49 commit a2c1022
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions scripts/wingetUpdateAll.ps1.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Script is executable and self-elevating when renamed *.cmd or *.bat

# Import known folder
$env:CommonDesktop = New-Object -ComObject Shell.Application).NameSpace('shell:Common Desktop').Self.Path
$env:Desktop = New-Object -ComObject Shell.Application).NameSpace('shell:Desktop').Self.Path
$env:CommonDesktop = (New-Object -ComObject Shell.Application).NameSpace('shell:Common Desktop').Self.Path
$env:Desktop = (New-Object -ComObject Shell.Application).NameSpace('shell:Desktop').Self.Path

# Update all winget applications
winget upgrade --all
Expand Down
10 changes: 9 additions & 1 deletion source/trayMenu.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ handler(itemName, itemPosition, menu) {
Send action.send
}
if action.hasOwnProp("run") {
Run action.run
file := NormalizePath(action.run)
Run file, A_WorkingDir
}
if action.HasOwnProp("switch") {
menu.ToggleCheck(itemName)
Expand All @@ -340,4 +341,11 @@ findAction(&menu, text) {
}
}
return false ; couldn't find item
}

NormalizePath(path) {
cc := DllCall("GetFullPathName", "str", path, "uint", 0, "ptr", 0, "ptr", 0, "uint")
buf := Buffer(cc * 2)
DllCall("GetFullPathName", "str", path, "uint", cc, "ptr", buf, "ptr", 0)
return StrGet(buf)
}

0 comments on commit a2c1022

Please sign in to comment.