clean_env.bat 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. echo off
  2. echo =====================================================================
  3. echo Salt Windows Clean Script
  4. echo =====================================================================
  5. echo.
  6. rem Make sure the script is run as Admin
  7. echo Administrative permissions required. Detecting permissions...
  8. echo ---------------------------------------------------------------------
  9. net session >nul 2>&1
  10. if %errorLevel%==0 (
  11. echo Success: Administrative permissions confirmed.
  12. ) else (
  13. echo Failure: This script must be run as Administrator
  14. goto eof
  15. )
  16. echo.
  17. :CheckPython27
  18. if exist "\Python27" goto RemovePython27
  19. goto CheckPython35
  20. :RemovePython27
  21. rem Uninstall Python 2.7
  22. echo %0 :: Uninstalling Python 2 ...
  23. echo ---------------------------------------------------------------------
  24. echo %0 :: - 2.7.12 (32 bit)
  25. MsiExec.exe /X {9DA28CE5-0AA5-429E-86D8-686ED898C665} /QN
  26. echo %0 :: - 2.7.12 (64 bit)
  27. MsiExec.exe /X {9DA28CE5-0AA5-429E-86D8-686ED898C666} /QN
  28. echo %0 :: - 2.7.13 (32 bit)
  29. MsiExec.exe /X {4A656C6C-D24A-473F-9747-3A8D00907A03} /QN
  30. echo %0 :: - 2.7.13 (64 bit)
  31. MsiExec.exe /X {4A656C6C-D24A-473F-9747-3A8D00907A04} /QN
  32. echo %0 :: - 2.7.14 (32 bit)
  33. MsiExec.exe /X {0398A685-FD8D-46B3-9816-C47319B0CF5E} /QN
  34. echo %0 :: - 2.7.14 (64 bit)
  35. MsiExec.exe /X {0398A685-FD8D-46B3-9816-C47319B0CF5F} /QN
  36. echo %0 :: - 2.7.15 (32 bit)
  37. MsiExec.exe /X {16CD92A4-0152-4CB7-8FD6-9788D3363616} /QN
  38. echo %0 :: - 2.7.15 (64 bit)
  39. MsiExec.exe /X {16CD92A4-0152-4CB7-8FD6-9788D3363617} /QN
  40. echo.
  41. rem Wipe the Python directory
  42. echo %0 :: Removing the C:\Python27 Directory ...
  43. echo ---------------------------------------------------------------------
  44. rd /s /q C:\Python27
  45. if %errorLevel%==0 (
  46. echo Successful
  47. ) else (
  48. echo Failed, please remove manually
  49. )
  50. :CheckPython35
  51. if exist "\Python35" goto RemovePython35
  52. goto CheckPython37
  53. :RemovePython35
  54. echo %0 :: Uninstalling Python 3 ...
  55. echo ---------------------------------------------------------------------
  56. :: 64 bit
  57. if exist "%LOCALAPPDATA%\Package Cache\{b94f45d6-8461-440c-aa4d-bf197b2c2499}" (
  58. echo %0 :: - 3.5.3 64bit
  59. "%LOCALAPPDATA%\Package Cache\{b94f45d6-8461-440c-aa4d-bf197b2c2499}\python-3.5.3-amd64.exe" /uninstall /quiet
  60. )
  61. if exist "%LOCALAPPDATA%\Package Cache\{5d57524f-af24-49a7-b90b-92138880481e}" (
  62. echo %0 :: - 3.5.4 64bit
  63. "%LOCALAPPDATA%\Package Cache\{5d57524f-af24-49a7-b90b-92138880481e}\python-3.5.4-amd64.exe" /uninstall /quiet
  64. )
  65. :: 32 bit
  66. if exist "%LOCALAPPDATA%\Package Cache\{a10037e1-4247-47c9-935b-c5ca049d0299}" (
  67. echo %0 :: - 3.5.3 32bit
  68. "%LOCALAPPDATA%\Package Cache\{a10037e1-4247-47c9-935b-c5ca049d0299}\python-3.5.3" /uninstall /quiet
  69. )
  70. if exist "%LOCALAPPDATA%\Package Cache\{06e841fa-ca3b-4886-a820-cd32c614b0c1}" (
  71. echo %0 :: - 3.5.4 32bit
  72. "%LOCALAPPDATA%\Package Cache\{06e841fa-ca3b-4886-a820-cd32c614b0c1}\python-3.5.4" /uninstall /quiet
  73. )
  74. rem wipe the Python directory
  75. echo %0 :: Removing the C:\Python35 Directory ...
  76. echo ---------------------------------------------------------------------
  77. rd /s /q "C:\Python35"
  78. if %errorLevel%==0 (
  79. echo Successful
  80. ) else (
  81. echo Failed, please remove manually
  82. )
  83. goto eof
  84. :CheckPython37
  85. if exist "\Python37" goto RemovePython37
  86. goto eof
  87. :RemovePython37
  88. echo %0 :: Uninstalling Python 3.7 ...
  89. echo ---------------------------------------------------------------------
  90. :: 64 bit
  91. if exist "%LOCALAPPDATA%\Package Cache\{8ae589dd-de2e-42cd-af56-102374115fee}" (
  92. echo %0 :: - 3.7.4 64bit
  93. "%LOCALAPPDATA%\Package Cache\{8ae589dd-de2e-42cd-af56-102374115fee}\python-3.7.4-amd64.exe" /uninstall /quiet
  94. )
  95. :: 32 bit
  96. if exist "%LOCALAPPDATA%\Package Cache\{b66087e3-469e-4725-8b9b-f0981244afea}" (
  97. echo %0 :: - 3.7.4 32bit
  98. "%LOCALAPPDATA%\Package Cache\{b66087e3-469e-4725-8b9b-f0981244afea}\python-3.7.4" /uninstall /quiet
  99. )
  100. :: Python Launcher, seems to be the same for 32 and 64 bit
  101. echo %0 :: - Python Launcher
  102. msiexec.exe /x {D722DA3A-92F5-454A-BD5D-A48C94D82300} /quiet /qn
  103. rem wipe the Python directory
  104. echo %0 :: Removing the C:\Python37 Directory ...
  105. echo ---------------------------------------------------------------------
  106. rd /s /q "C:\Python37"
  107. if %errorLevel%==0 (
  108. echo Successful
  109. ) else (
  110. echo Failed, please remove manually
  111. )
  112. goto eof
  113. :eof
  114. echo.
  115. echo =====================================================================
  116. echo End of %0
  117. echo =====================================================================