Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- :: Comment this for debugging
- @ECHO off
- ::
- :: Transform a shortcut to a directory ".lnk" file into a Junction
- ::
- :: Usage: shctdir2junct "C:\path to\shortcut.lnk"
- ::
- :: Drag a directory shortcut into this batch file to transform it into a junction at the same directory!
- ::
- :: WARNING: Do not use this program with file shortcuts, directory shortcuts only please!
- :: WARNING: This will delete the original shortcut even if the script fails to create the junction,
- :: turn on pause and turn off @echo off to debug
- ::
- :: By JBud
- ::
- SET Shortcut="%1"
- ::
- :: Parse the shortcut for target value
- ::
- ECHO SET WshShell = WScript.CreateObject("WScript.Shell")>DecodeShortCut.vbs
- ECHO SET Lnk = WshShell.CreateShortcut(WScript.Arguments.Unnamed(0))>>DecodeShortCut.vbs
- ECHO wscript.Echo Lnk.TargetPath>>DecodeShortCut.vbs
- SET vbscript=cscript //nologo DecodeShortCut.vbs
- FOR /f "delims=" %%T IN ( ' %vbscript% "%Shortcut%" ' ) DO SET target=%%T
- DEL DecodeShortCut.vbs
- ::
- ::
- ECHO.
- ECHO.
- ECHO.
- ::
- :: Remove .lnk from the shortcut name
- ::
- SET _scut=%shortcut%
- SET _junction=%_scut:.lnk=%
- ::
- ::
- ECHO Transforming shortcut: "%Shortcut%", into junction: "%_junction%", for target: "%target%"...
- ::
- ::
- ECHO.
- ECHO.
- ECHO.
- ::
- :: Make the junction
- MKLINK /J "%_junction%" "%target%"
- ::
- :: Delete the original shortcut
- DEL "%shortcut%"
- ::
- ::
- ECHO Done...
- ::
- :: Uncomment this for debugging
- ::PAUSE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement