Advertisement
gocha

Create Directory Junctions for Each Directories

Dec 2nd, 2014
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.28 KB | None | 0 0
  1. @rem Create Directory Junctions for Every Directories in A Directory
  2.  
  3. @rem http://stackoverflow.com/questions/7044985/how-can-i-auto-elevate-my-batch-file-so-that-it-requests-from-uac-admin-rights
  4. :::::::::::::::::::::::::::::::::::::::::
  5. :: Automatically check & get admin rights
  6. :::::::::::::::::::::::::::::::::::::::::
  7. :checkPrivileges
  8. @NET FILE 1>NUL 2>NUL
  9. @if '%errorlevel%' == '0' ( @goto gotPrivileges ) else ( @goto getPrivileges )
  10.  
  11. :getPrivileges
  12. @if '%1'=='ELEV' (@shift & goto gotPrivileges)  
  13.  
  14. @setlocal DisableDelayedExpansion
  15. @set "batchPath=%~0"
  16. @setlocal EnableDelayedExpansion
  17. @ECHO Set UAC = CreateObject^("Shell.Application"^) > "%temp%\OEgetPrivileges.vbs"
  18. @ECHO UAC.ShellExecute "!batchPath!", "ELEV", "", "runas", 1 >> "%temp%\OEgetPrivileges.vbs"
  19. @"%temp%\OEgetPrivileges.vbs"
  20. @exit /B
  21.  
  22. :gotPrivileges
  23. ::::::::::::::::::::::::::::
  24. ::START
  25. ::::::::::::::::::::::::::::
  26.  
  27. @setlocal
  28.  
  29. @set PREV_DIR=%CD%
  30. @set LIB_LOGICAL_DIR=D:\Users\Public\Documents\Sample Library
  31. @set LIB_PHYSICAL_DIR=G:\Sample Library
  32.  
  33. echo %LIB_PHYSICAL_DIR% にあるフォルダを %LIB_LOGICAL_DIR% にリンクします。
  34. @cd /d "%LIB_PHYSICAL_DIR%"
  35. @for /d %%a in (*) do @mklink /D "%LIB_LOGICAL_DIR%\%%a" "%LIB_PHYSICAL_DIR%\%%a"
  36.  
  37. @cd /d "%PREV_DIR%"
  38.  
  39. @endlocal
  40. @pause
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement