Skip to content

Commit b7a591a

Browse files
committed
Rename, Patch, and Improve _IsPriviledgedInstall
1 parent 2d8d83c commit b7a591a

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

MSEdgeRedirect_Wrapper.au3

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
; TODO: Why have <Setting>PATH values for Custom handlers... Rewrite that.
2626

2727
Global $sVersion
28-
Global $bIsPriv = _IsPriviledgedInstall()
28+
Global $bIsPriv = _IsDestinationRestricted()
2929
Global Enum $bNoApps, $bNoBing, $bNoChat, $bNoFeed, $bNoImgs, $bNoMSN, $bNoNews, $bNoPDFs, $bNoPilot, $bNoSpotlight, $bNoTray, $bNoUpdates, $sFeed, $sFeedPath, $sImages, $sImagePath, $sNews, $sPDFApp, $sSearch, $sSearchPath, $sStartMenu, $bStartup, $sWeather, $sWeatherPath
3030

3131
If @Compiled Then
@@ -1473,22 +1473,27 @@ Func _IsInstalled()
14731473

14741474
EndFunc
14751475

1476-
; TODO: Rename. Detects if script install directory requires admin rights
1477-
Func _IsPriviledgedInstall()
1476+
Func _IsDestinationRestricted($sDirectory = Null)
14781477

14791478
Local $hTestFile
14801479

1481-
If @ScriptDir = $sDrive & "\Program Files\MSEdgeRedirect" Then
1482-
Return True
1483-
ElseIf @LocalAppDataDir & "\MSEdgeRedirect" Then
1484-
Return False
1485-
Else
1486-
$hTestFile = FileOpen(".\writetest", $FO_CREATEPATH)
1487-
If @error Then
1480+
Select
1481+
Case @ScriptDir = $sDrive & "\Program Files\MSEdgeRedirect"
14881482
Return True
1489-
Else
1490-
FileDelete($hTestFile)
1483+
Case @ScriptDir = @LocalAppDataDir & "\MSEdgeRedirect"
14911484
Return False
1492-
EndIf
1485+
Case $sDirectory <> Null
1486+
$hTestFile = FileOpen(".\writetest", $FO_CREATEPATH+$FO_OVERWRITE)
1487+
Case Else
1488+
$hTestFile = FileOpen(".\writetest", $FO_CREATEPATH+$FO_OVERWRITE)
1489+
1490+
EndSelect
1491+
1492+
If @error Then ; Did FileOpen Fail?
1493+
Return True
1494+
Else
1495+
FileDelete($hTestFile)
1496+
Return False
14931497
EndIf
1498+
14941499
EndFunc

0 commit comments

Comments
 (0)