Skip to content

Instantly share code, notes, and snippets.

@HoldYourWaffle
Created May 26, 2023 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HoldYourWaffle/a19766d7d965024339bc606a18ec2a4a to your computer and use it in GitHub Desktop.
Save HoldYourWaffle/a19766d7d965024339bc606a18ec2a4a to your computer and use it in GitHub Desktop.
AutoHotkey - Get directory junction target
#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