You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.6 KiB

8 years ago
8 years ago
  1. @SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
  2. @ECHO OFF
  3. SET CMDLINERUNSTR=%SystemRoot%\system32\cmd.exe
  4. DEL script1.log > NUL 2>&1
  5. DEL add-paths.log > NUL 2>&1
  6. DEL add-paths-detail.log > NUL 2>&1
  7. DEL UPDATE > NUL 2>&1
  8. ELEVATE -wait add-paths.bat >> script1.log 2>&1
  9. IF ERRORLEVEL 1 (
  10. ECHO You denied admin access. Rerun the script, and be sure to press the yes button this time.
  11. ) ELSE (
  12. TYPE add-paths.log 2> NUL
  13. )
  14. ECHO.
  15. :: Branch to UpdateEnv if we need to update
  16. IF EXIST UPDATE (
  17. DEL UPDATE
  18. GOTO UpdateEnv
  19. )
  20. GOTO ExitBatch
  21. :: -----------------------------------------------------------------------------
  22. :UpdateEnv
  23. ECHO Making updated PATH go live . . .
  24. REG delete HKCU\Environment /F /V TEMPVAR > NUL 2>&1
  25. setx TEMPVAR 1 > NUL
  26. REG delete HKCU\Environment /F /V TEMPVAR > NUL 2>&1
  27. IF NOT !cmdcmdline! == !CMDLINERUNSTR! (CALL :KillExplorer)
  28. GOTO ExitBatch
  29. :: -----------------------------------------------------------------------------
  30. :ExitBatch
  31. ENDLOCAL
  32. PAUSE
  33. EXIT /b
  34. :: -----------------------------------------------------------------------------
  35. :KillExplorer
  36. ECHO.
  37. ECHO.
  38. ECHO Your desktop will be restarted.
  39. ECHO.
  40. ECHO All file explorer windows except for the one you launched this script from WILL BE CLOSED.
  41. ECHO.
  42. ECHO Press enter when ready, or close this window if you would rather do a full restart of your computer at a later time.
  43. ECHO.
  44. PAUSE
  45. ping -n 5 127.0.0.1 > NUL 2>&1
  46. ECHO Killing process Explorer.exe. . .
  47. ECHO.
  48. taskkill /f /im explorer.exe > NUL
  49. ECHO.
  50. ECHO Your desktop is now loading. . .
  51. ECHO.
  52. ping -n 5 127.0.0.1 > NUL 2>&1
  53. START explorer.exe
  54. START explorer.exe %CD%
  55. EXIT /b