Advertisement
Guest User

Untitled

a guest
Aug 11th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.41 KB | None | 0 0
  1. :: Comment this for debugging
  2. @ECHO off
  3. ::
  4. :: Transform a shortcut to a directory ".lnk" file into a Junction
  5. ::
  6. :: Usage: shctdir2junct "C:\path to\shortcut.lnk"
  7. ::
  8. :: Drag a directory shortcut into this batch file to transform it into a junction at the same directory!
  9. ::
  10. :: WARNING: Do not use this program with file shortcuts, directory shortcuts only please!
  11. :: WARNING: This will delete the original shortcut even if the script fails to create the junction,
  12. ::          turn on pause and turn off @echo off to debug
  13. ::
  14. :: By JBud
  15. ::
  16. SET Shortcut="%1"
  17. ::
  18. :: Parse the shortcut for target value
  19. ::
  20. ECHO SET WshShell = WScript.CreateObject("WScript.Shell")>DecodeShortCut.vbs
  21. ECHO SET Lnk = WshShell.CreateShortcut(WScript.Arguments.Unnamed(0))>>DecodeShortCut.vbs
  22. ECHO wscript.Echo Lnk.TargetPath>>DecodeShortCut.vbs
  23. SET vbscript=cscript //nologo DecodeShortCut.vbs
  24. FOR /f "delims=" %%T IN ( ' %vbscript% "%Shortcut%" ' ) DO SET target=%%T
  25. DEL DecodeShortCut.vbs
  26. ::
  27. ::
  28. ECHO.
  29. ECHO.
  30. ECHO.
  31. ::
  32. :: Remove .lnk from the shortcut name
  33. ::
  34. SET _scut=%shortcut%
  35. SET _junction=%_scut:.lnk=%
  36. ::
  37. ::
  38. ECHO Transforming shortcut: "%Shortcut%", into junction: "%_junction%", for target: "%target%"...
  39. ::
  40. ::
  41. ECHO.
  42. ECHO.
  43. ECHO.
  44. ::
  45. :: Make the junction
  46. MKLINK /J "%_junction%" "%target%"
  47. ::
  48. :: Delete the original shortcut
  49. DEL "%shortcut%"
  50. ::
  51. ::
  52. ECHO Done...
  53. ::
  54. :: Uncomment this for debugging
  55. ::PAUSE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement