Created
May 26, 2023 18:56
-
-
Save HoldYourWaffle/a19766d7d965024339bc606a18ec2a4a to your computer and use it in GitHub Desktop.
AutoHotkey - Get directory junction target
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requires AutoHotkey v2.0 | |
GetJunctionTarget(Path) { | |
OutLogPath := A_Temp . "\AHK-GetJunctionTarget-fsutil.txt" | |
fsutil := A_ComSpec . " /c fsutil reparsepoint query `"" . Path . "`" > `"" . OutLogPath . "`"" | |
ExitCode := RunWait(fsutil) | |
if (ExitCode != 0) { | |
throw Error(fsutil . " exited with exit code " . ExitCode) | |
} | |
Loop Read OutLogPath { | |
RegExMatch(A_LoopReadLine, "^Print Name: +(.*)$", &Match) | |
if (Match != "") { | |
return Match[1] | |
} | |
} | |
throw Error("No 'Print Name' in " . fsutil . " output") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment