6
\$\begingroup\$

I made this to help new techs be more proficient while they are learning. I know most of it is common knowledge around here. I would also like to point out that I don't really know batch but I am learning. Feel free to copy, share or contribute. This should work on XP, Vista, 7, 8, 8.1, and 10 but it's not 100% tested on all versions so some things might not work correctly.

Shortcuts and Kill a Process ****REMOVE FOR BODY LIMIT****

Full code can be found here. Updated 12-14-2014

@echo off
mode con: cols=86 lines=38
Title =  ---- Control Center -----

: Control_Center
color 9F&prompt $v
echo.
echo.
echo                           Control Center 
echo. 
echo. 
echo      ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo      º                                                                º
echo      º                                                                º
echo      º  Please Make a Choice By typing the corresponding number...    º
echo      º                                                                º
echo      º                                                                º
echo      º  1.  Shortcuts ****REMOVE FOR BODY LIMIT****                   º
echo      º  2.  Printer Repair                                            º
echo      º  3.  Internet Repair                                           º
echo      º  4.  Repair OS                                                 º
echo      º  5.  Kill a Process ****REMOVE FOR BODY LIMIT****              º
echo      º  6.  UAC (User Account Controls)                               º
echo      º  7.  Activate Admin Account                                    º
echo      º  8.  S.M.A.R.T Status of Hard Drive (C)                        º
echo      º  9.  (F8) Enable legacy mode     (Windows 8/8.1 only)          º
echo      º  10. Reboot to Safe Mode with Networking                       º
echo      º  11. Clean Up after Virus Removal                              º
echo      º  12. Empty Temp Folders                                        º
echo      º  13. Empty Recycling Bin                                       º
echo      º  14. Software_Distribution                                     º
echo      º  0.  Exit                                                      º
echo      º                                                                º
Echo      ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
echo.
echo.
echo.

set /a counter=0
set /p option= Enter Choice.....
set /a counter= %counter%+%option%
if %option%==1  goto Shortcut_Center
if %option%==2  goto Printer_Repair   
if %option%==3  goto Internet_Repair
if %option%==4  goto Repair_OS 
if %option%==5  goto Kill_Process
if %option%==6  goto UAC
if %option%==7  goto Admin_Account
if %option%==8  goto Smart_Status
if %option%==9  goto Enable_legacy_Mode 
if %option%==10  goto Safe_Reboot_Net
if %option%==11  goto Clean_up
if %option%==12  goto Empty_Temp_Folders
if %option%==13  goto Empty_Trash
if %option%==14  goto Software_Distribution
if %option%==0   goto Exit

ECHO.
ECHO "%choice%" is not valid...please try again
pause
cls
goto Control_Center

: Exit
exit

cls
goto Control_Center


: Software_Distribution

@echo off 

SET /P ANSWER=What would you like to do with the Software Distribution Folder? (R) Rename or (D) Delete ...  
echo You chose: %ANSWER% 
if /i {%ANSWER%}=={R} (goto :Rename_Software_Distribution) 
if /i {%ANSWER%}=={D} (goto :Delete_Software_Distribution) 

:Rename_Software_Distribution
net stop wuauserv
ren %windir%\SoftwareDistribution SD.old
net start wuauserv
wuauclt.exe /detectnow
Pause
cls
goto Control_Center

:Delete_Software_Distribution
net stop wuauserv
del /f /s /q %windir%\SoftwareDistribution\*.*
net start wuauserv
wuauclt.exe /detectnow
Pause 
cls
goto Control_Center

: Empty_Trash
Echo Off

REM Check Windows Version
ver | findstr /i "5\.0\." > nul
IF %ERRORLEVEL% EQU 0 goto ver5x
ver | findstr /i "5\.1\." > nul
IF %ERRORLEVEL% EQU 0 goto ver5x
ver | findstr /i "5\.2\." > nul
IF %ERRORLEVEL% EQU 0 goto ver5x
ver | findstr /i "6\.0\." > nul
IF %ERRORLEVEL% EQU 0 goto ver6x
ver | findstr /i "6\.1\." > nul
IF %ERRORLEVEL% EQU 0 goto ver6x
ver | findstr /i "6\.2\." > nul
IF %ERRORLEVEL% EQU 0 goto ver6x
ver | findstr /i "6\.3\." > nul
IF %ERRORLEVEL% EQU 0 goto ver6x
ver | findstr /i "6\.4\." > nul
IF %ERRORLEVEL% EQU 0 goto ver6x
goto warn_and_exit

:ver5x
rd /s c:\recycler
pause
cls
goto Control_Center

:ver6x
rd /s c:\$Recycle.Bin
pause
cls
goto Control_Center

Echo On

:warn_and_exit
echo Machine OS cannot be determined.

cls
pause
goto Control_Center

: Empty_Temp_Files

erase "%TEMP%\*.*" /f /s /q
for /D %%i in ("%TEMP%\*") do RD /S /Q "%%i"

erase "%TMP%\*.*" /f /s /q
for /D %%i in ("%TMP%\*") do RD /S /Q "%%i"

erase "%ALLUSERSPROFILE%\TEMP\*.*" /f /s /q
for /D %%i in ("%ALLUSERSPROFILE%\TEMP\*") do RD /S /Q "%%i"

erase "%SystemRoot%\TEMP\*.*" /f /s /q
for /D %%i in ("%SystemRoot%\TEMP\*") do RD /S /Q "%%i"

pause
cls
goto Control_Center

: Clean_up
cls
cd c:

echo Looking for traces of Rkill
echo Please wait.....
del /q /s /f "C:\Users\%username%\Desktop\Rkill*.txt"
echo.

echo Looking for Rkill folder to delete
echo Please wait.....
RD /S /Q "C:\Users\%username%\Desktop\rkill"
echo.

echo Looking for traces of TDSSKiller
echo Please wait.....
del /q /s /f "C:\TDSSKiller*.txt"
echo.

echo Looking for Old Downloads of Logmein                   
echo Please wait.....
del /q /s /f "c:\users\%username%\Downloads\Support-LogMeInRescue*.exe"
echo.

echo Looking for Old Downloads of Team Viewer
echo Please wait.....
del /q /s /f "c:\users\%username%\Downloads\TeamViewerQS*.exe"
echo.

echo Looking for traces Rkreports
echo Please wait.....
del /q /s /f "C:\Users\%username%\Desktop\RKreport*.txt"
echo.

echo Looking for Rk_Quarantine folder to delete
echo Please wait.....
RD /S /Q "C:\Users\%username%\Desktop\RK_Quarantine"
echo.

echo Looking for Old AdwCleaner Folder to delete
echo Please wait.....
RD /S /Q "C:\AdwCleaner"
echo.

echo Looking to see if Combofix has ran and save the log report to the GOS folder
echo Please wait.....
MOVE /Y "C:\ComboFix.txt" C:\
echo.

echo Looking to Deleting Combofix off of the desktop if its there
echo Please wait.......
del /q /s /f "C:\Users\%username%\Desktop\ComboFix.exe"
echo.

echo Looking to save the MBAR folder from the desktop to the GOS folder if its been used
echo Please wait.....
MOVE /y "c:\Users\%username%\Desktop\mbar" c:\
echo.

echo.
echo.
echo                        All Cleanup has been performed
echo.
Pause
cls
goto Control_Center

: Safe_Reboot_Net
Echo Off

REM Check Windows Version
ver | findstr /i "5\.0\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_nt5x
ver | findstr /i "5\.1\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_nt5x
ver | findstr /i "5\.2\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_nt5x
ver | findstr /i "6\.0\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_nt6x
ver | findstr /i "6\.1\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_nt6x
ver | findstr /i "6\.2\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_nt6x
ver | findstr /i "6\.3\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_nt6x
ver | findstr /i "6\.4\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_nt6x
goto warn_and_exit

:ver_nt5x
bootcfg /raw /a /safeboot:network /id 1
REG ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce /v "*UndoSB" /t REG_SZ /d "bootcfg /raw /fastdetect /id 1"
SHUTDOWN -r -f -t 07
goto Control_Center

:ver_nt6x
bcdedit /set {current} safeboot network
REG ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce /v "*UndoSB" /t REG_SZ /d "bcdedit /deletevalue {current} safeboot"
SHUTDOWN -r -f -t 07
goto Control_Center

Echo On

:warn_and_exit
echo Machine OS cannot be determined.

cls
pause
goto Control_Center

: Enable_legacy_Mode 
bcdedit /set {default} bootmenupolicy legacy
pause
cls
goto Control_Center

: Smart_Status
wmic diskdrive get status
pause
cls
goto Control_Center

: Admin_Account 
@echo off 

SET /P ANSWER=What state do you want the admin account? (E) Enabled or (D) Disabled ...  
echo You chose: %ANSWER% 
if /i {%ANSWER%}=={E} (goto :Enable_Admin) 
if /i {%ANSWER%}=={D} (goto :Disable_Admin) 

:Enable_Admin
net user administrator /active:yes
Pause
cls
goto Control_Center

:Disable_Admin
net user administrator /active:no
Pause 
cls
goto Control_Center

: UAC
mode con: cols=86 lines=38
color 9F&prompt $v
cls
echo.
echo.
echo.
echo.
echo                       User Account Controls
echo.
echo. 
echo      ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo      º                                                                º
echo      º                                                                º
echo      º  Please Make a Choice By typing the corresponding number...    º
echo      º                                                                º
echo      º                                                                º
echo      º  1. Turn Off UAC                                               º
echo      º  2. Turn on UAC                                                º
echo      º  3. Open UAC                                                   º
echo      º  0. Cancel                                                     º 
echo      º                                                                º
echo      º                                                                º
echo      º                                                                º
Echo      ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
echo.
echo.
echo.
set /p option= Enter Choice.....
echo.
echo.
if %option%==1  goto Turn_Off_UAC
if %option%==2  goto Turn_On_UAC
if %option%==3  goto Open_UAC
if %option%==0  goto Cancel
ECHO.
ECHO "%choice%" is not valid...please try again
pause
cls
goto UAC

: Open_UAC
C:\Windows\System32\UserAccountControlSettings.exe
pause
cls
goto UAC

: Turn_On_UAC
C:\Windows\System32\cmd.exe /k %windir%\System32\reg.exe ADD  HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v  EnableLUA /t REG_DWORD /d 1 /f
cls
goto UAC

: Turn_Off_UAC
C:\Windows\System32\cmd.exe /k %windir%\System32\reg.exe ADD  HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v  EnableLUA /t REG_DWORD /d 0 /f
cls
goto UAC

: Repair_OS
mode con: cols=86 lines=38
color 9F&prompt $v
cls
echo.
echo.
echo.
echo.
echo                           Repair OS
echo.
echo. 
echo      ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo      º                                                                º
echo      º                                                                º
echo      º  Please Make a Choice By typing the corresponding number...    º
echo      º                                                                º
echo      º                                                                º
echo      º  1. SFC Scan                                                   º
echo      º  2. Check Disk                                                 º
echo      º  3. Dism Restore Health         (Windows 8/8.1 Only)           º
echo      º  4. System Update Readiness Tool - Website   (Vista and 7)     º
echo      º  5. Troubleshooting                                            º
echo      º  6. Malicious Software Removal Tool                            º
echo      º  7. System Restore                                             º
echo      º  0. Cancel                                                     º 
echo      º                                                                º
echo      º                                                                º
echo      º                                                                º
Echo      ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
echo.
echo.
echo.
set /p option= Enter Choice.....
echo.
echo.
if %option%==1  goto SFC_Scan
if %option%==2  goto Check_Disk   
if %option%==3  goto Dism_Restore_Health
if %option%==4  goto System_Update  
if %option%==5  goto Troubleshooting
if %option%==6  goto Malicious_Software_Removal_Tool 
if %option%==7  goto System_Restore 
if %option%==0  goto Cancel_Repair_OS
ECHO.
ECHO "%choice%" is not valid...please try again
pause
cls
goto Repair_OS

: Cancel_Repair_OS
cls
goto Control_Center

: System_Restore
Echo Off

REM Check Windows Version
ver | findstr /i "5\.0\." > nul
IF %ERRORLEVEL% EQU 0 goto nt5
ver | findstr /i "5\.1\." > nul
IF %ERRORLEVEL% EQU 0 goto nt5
ver | findstr /i "5\.2\." > nul
IF %ERRORLEVEL% EQU 0 goto nt5
ver | findstr /i "6\.0\." > nul
IF %ERRORLEVEL% EQU 0 goto nt6
ver | findstr /i "6\.1\." > nul
IF %ERRORLEVEL% EQU 0 goto nt6
ver | findstr /i "6\.2\." > nul
IF %ERRORLEVEL% EQU 0 goto nt6
ver | findstr /i "6\.3\." > nul
IF %ERRORLEVEL% EQU 0 goto nt6
ver | findstr /i "6\.4\." > nul
IF %ERRORLEVEL% EQU 0 goto nt6
goto warn

:nt5
%SystemRoot%\system32\restore\rstrui.exe
cls
goto Repair_OS

:nt6
systempropertiesprotection
cls
goto Repair_OS

Echo On

:warn
echo Machine OS cannot be determined.

Pause
cls
goto Repair_OS

: Malicious_Software_Removal_Tool
mrt
cls
goto Repair_OS

: Troubleshooting
control.exe /name Microsoft.Troubleshooting
cls
goto Repair_OS

: System_Update
Start http://support.microsoft.com/kb/947821/en-us
cls
goto Repair_OS

: Dism_Restore_Health
Dism /Online /Cleanup-Image /RestoreHealth
Pause
cls
goto Control_Center

: Check_Disk 
chkdsk
Pause
cls
goto Repair_OS 

: SFC_Scan
sfc /scannow
Pause
cls
goto Repair_OS

: Internet_Repair
mode con: cols=86 lines=38
color 9F&prompt $v
cls
echo.
echo.
echo.
echo.
echo                          Internet Repair
echo.
echo. 
echo      ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo      º                                                                º
echo      º                                                                º
echo      º  Please Make a Choice By typing the corresponding number...    º
echo      º                                                                º
echo      º                                                                º
echo      º  1.  Inspect Host                                              º
echo      º  2.  Remove Proxy                                              º
echo      º  3.  Uninstall Browser                                         º
echo      º  4.  Reset Browser                                             º
echo      º  5.  Ping Test and IP Info                                     º
echo      º  6.  Flush IP DNS and Reset Winsock (Auto Reboot)              º
echo      º  7.  Internet Properties                                       º
echo      º  8.  Network and Sharing Center                                º
echo      º  9.  Network Connections                                       º
echo      º  10. Windows Firewall                                          º
echo      º  11. Internet Explorer No Add-Ons                              º
echo      º  0.  Cancel                                                    º 
echo      º                                                                º
echo      º                                                                º
echo      º                                                                º
Echo      ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
echo.
echo.
echo.
set /a counter=0
set /p option= Enter Choice.....
set /a counter= %counter%+%option%
if %option%==1   goto Inspect_Host
if %option%==2   goto Remove_Proxy   
if %option%==3   goto Uninstall_Browser
if %option%==4   goto Reset_Browser
if %option%==5   goto Ping_Test
if %option%==6   goto Flush_and_Reset
if %option%==7   goto Internet_Properties_IR
if %option%==8   goto Network_and_Sharing_Center
if %option%==9   goto Network_Connections
if %option%==10  goto Windows_Firewall
if %option%==11  goto IE_NO_Add
if %option%==0   goto Cancel_Internet_Repair
ECHO.
ECHO "%choice%" is not valid...please try again
pause
cls
goto Internet_Repair

: Cancel_Internet_Repair
cls
goto Control_Center

: IE_No_Add
start iexplore.exe -extoff "64.233.176.103"
cls
goto Internet_Repair

: Windows_Firewall
@echo off 

SET /P ANSWER=What state do you want the Windows Firewall in? (1) Inabled (2) Disabled ...  
echo You chose: %ANSWER% 
if /i {%ANSWER%}=={1} (goto :Inable_Firewall) 
if /i {%ANSWER%}=={2} (goto :Disable_Firewall) 

:Inable_Firewall
netsh irewall set opmode enable
cls
ECHO.
ECHO.
echo Windows Firewall is now ON
pause
cls
goto Internet_Repair

:Disable_Firewall
netsh firewall set opmode disable
cls
ECHO.
ECHO.
echo Windows Firewall is now OFF
cls
pause
cls
goto Internet_Repair

: Network_Connections
control netconnections
cls
goto Internet_Repair

: Network_and_Sharing_Center
control.exe /name Microsoft.NetworkAndSharingCenter
cls
goto Internet_Repair

: Internet_Properties_IR
Inetcpl.cpl
cls
goto Internet_Repair

: Flush_and_Reset
ipconfig /flushdns
netsh winsock reset
shutdown /r

: Ping_Test
mode con: cols=100 lines=48
start cmd /k ping www.google.com -t
ipconfig /all
pause
cls
goto Internet_Repair

: Reset_Browser
mode con: cols=86 lines=38
color 9F&prompt $v
cls
echo.
echo.
echo.
echo.
echo                          Reset Browser
echo.
echo. 
echo      ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo      º                                                                º
echo      º                                                                º
echo      º  Please Make a Choice By typing the corresponding number...    º
echo      º                                                                º
echo      º                                                                º
echo      º  1. Manuall Reset Internet Explorer Settings                   º
echo      º  2. Reset Chrome                                               º
echo      º  3. Reset Firefox                                              º
echo      º  4. Delete IE Cache                                            º
echo      º  5. Delete Google Chrome Cache                                 º
echo      º  6. Delete Firefox Cache                                       º
echo      º  0. Cancel                                                     º 
echo      º                                                                º
echo      º                                                                º
echo      º                                                                º
Echo      ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
echo.
echo.
echo.
set /p option= Enter Choice.....
echo.
echo.
if %option%==1  goto  Reset_IE
if %option%==2  goto  Reset_Chrome  
if %option%==3  goto  Reset_Firefox
if %option%==4  goto  Delete_IE_Cache
if %option%==5  goto  Delete_Google_Cache
if %option%==6  goto  Delete_Firefox_Cache
if %option%==0  goto Cancel_Reset_Browser 
ECHO.
ECHO "%choice%" is not valid...please try again
pause
cls
goto Reset_Browser

: Cancel_Reset_Browser
cls
goto Internet_Repair

: Delete_Firefox_Cache
@rem Clear Firefox cache
erase "%LOCALAPPDATA%\Mozilla\Firefox\Profiles\*.*" /f /s /q
for /D %%i in ("%LOCALAPPDATA%\Mozilla\Firefox\Profiles\*") do RD /S /Q "%%i"
pause
cls
goto Internet_Repair

: Delete_Google_Cache
@rem Clear Google Chrome cache
erase "%LOCALAPPDATA%\Google\Chrome\User Data\*.*" /f /s /q
for /D %%i in ("%LOCALAPPDATA%\Google\Chrome\User Data\*") do RD /S /Q "%%i"
pause
cls
goto Internet_Repair

: Delete_IE_Cache
@rem Clear IE cache -  (Deletes Temporary Internet Files Only)
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8
erase "%LOCALAPPDATA%\Microsoft\Windows\Tempor~1\*.*" /f /s /q
for /D %%i in ("%LOCALAPPDATA%\Microsoft\Windows\Tempor~1\*") do RD /S /Q "%%i"
pause
cls
goto Internet_Repair

: Reset_Firefox
Firefox -safe-mode 
cls 
goto Reset_Browser

: Reset_IE
inetcpl.cpl
cls 
goto Reset_Browser

: Reset_Chrome
RD /S /Q "%UserProfile%\AppData\Local\Google\Chrome\User Data"
cls
goto Reset_Browser

: Uninstall_Browser
mode con: cols=86 lines=38
color 47&prompt $v
cls
echo.
echo.
echo.
echo.
echo                            Uninstall Browser
echo.
echo. 
echo      ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo      º                                                                º
echo      º                                                                º
echo      º  Please Make a Choice By typing the corresponding number...    º
echo      º                                                                º
echo      º                                                                º
echo      º  1. IE 11                                                      º
echo      º  2. IE 10                                                      º
echo      º  3. IE 9                                                       º
echo      º  4. IE 8                                                       º
echo      º  5. IE 7                                                       º
echo      º  6. Other                                                      º
echo      º  0. Cancel                                                     º 
echo      º                                                                º
echo      º                                                                º
echo      º                                                                º
Echo      ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
echo.
echo.
echo.
set /p option= Enter Choice.....
echo.
echo.
if %option%==1  goto IE_11
if %option%==2  goto IE_10    
if %option%==3  goto IE_9
if %option%==4  goto IE_8
if %option%==5  goto IE_7
if %option%==6  goto Browser_Other
if %option%==0  goto Cancel_IR
ECHO.
ECHO "%choice%" is not valid...please try again
pause
cls
goto Uninstall_Browser

: Cancel_IR
cls
goto Internet_Repair

: Browser_Other
appwiz.cpl
cls
goto Uninstall_Browser

: IE_7
%windir%\ie7\spuninst\spuninst.exe
pause
goto Control_Center

: IE_8
%windir%\ie8\spuninst\spuninst.exe.
pause
goto Control_Center

: IE_9
FORFILES /P %WINDIR%\servicing\Packages /M Microsoft-Windows-InternetExplorer-*9.*.mum /c "cmd /c echo Uninstalling package @fname && start /w pkgmgr /up:@fname /norestart"
pause
goto Control_Center

: IE_10
FORFILES /P %WINDIR%\servicing\Packages /M Microsoft-Windows-InternetExplorer-*10.*.mum /c "cmd /c echo Uninstalling package @fname && start /w pkgmgr /up:@fname /quiet /norestart"
pause
goto Control_Center

: IE_11
FORFILES /P %WINDIR%\servicing\Packages /M Microsoft-Windows-InternetExplorer-*11.*.mum /c "cmd /c echo Uninstalling package @fname && start /w pkgmgr /up:@fname /quiet /norestart"
pause
goto Control_Center 

: Remove_Proxy
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f
cls
goto Internet_Repair

: Inspect_Host
notepad C:\Windows\System32\drivers\etc\hosts
cls
goto Internet_Repair

: Printer_Repair
mode con: cols=86 lines=38
color 9F&prompt $v
cls
echo.
echo.
echo.
echo.
echo                       Printer Repair Options
echo.
echo. 
echo      ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo      º                                                                º
echo      º                                                                º
echo      º  Please Make a Choice By typing the corresponding number...    º
echo      º                                                                º
echo      º                                                                º
echo      º  1. Clear Printer Spooler                                      º
echo      º  2. Local Printers                                             º
echo      º  3. Device Manager                                             º
echo      º  4. Uninstall Printer                                          º
echo      º  5. Print Manager                                              º
echo      º  6. Open Print Spooler Folder                                  º
echo      º  0. Cancel                                                     º 
echo      º                                                                º
echo      º                                                                º
echo      º                                                                º
Echo      ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
echo.
echo.
echo.
set /p option= Enter Choice.....
echo.
echo.
if %option%==1  goto Clear_Printer
if %option%==2  goto Local_Printers   
if %option%==3  goto Device_Manager_PR
if %option%==4  goto Uninstall_Printer_PR
if %option%==5  goto Print_Manager
if %option%==6  goto Print_Spooler_Location
if %option%==0  goto Cancel_Printer_Repair_Options
ECHO.
ECHO "%choice%" is not valid...please try again
pause
cls
goto Printer_Repair

: Cancel_Printer_Repair_Options
cls
goto Control_Center

: Print_Spooler_Location
cd %windir%\System32\spool\PRINTERS
start.
cls
goto Printer_Repair

: Print_Manager
Printmanagement.msc
cls
goto Printer_Repair

: Uninstall_Printer_PR
appwiz.cpl
cls
goto Printer_Repair

: Device_Manager_PR
devmgmt.msc
cls
goto Printer_Repair

: Local_Printers
Control Printers
cls
goto Printer_Repair

: Clear_Printer
net stop spooler
del %systemroot%\System32\spool\printers\* /Q /F /S
net start spooler
pause
cls
goto Printer_Repair
\$\endgroup\$
  • \$\begingroup\$ @janos Please see the link to the full code. Its saved on a txt file and would need to be changed to a bat file and ran with admin rights to work correctly \$\endgroup\$ – Bobby Brown Dec 7 '14 at 15:04
  • \$\begingroup\$ It is our policy that you must include the code to be reviewed. External links can become obsolete. \$\endgroup\$ – janos Dec 7 '14 at 15:11
  • \$\begingroup\$ @janos The problem with that is the code is to many lines. What do you think I should do in this situation? \$\endgroup\$ – Bobby Brown Dec 7 '14 at 15:12
  • 1
    \$\begingroup\$ Cut it up to smaller reviewable pieces. \$\endgroup\$ – janos Dec 7 '14 at 15:22
  • 1
    \$\begingroup\$ Hopefully the reviews based on the subset of the code will give you ideas about how to improve the rest. Leave the link to the full version inside, in case somebody wants to see. There's nothing wrong with that. The reviews will focus on the part that's included. If after this review you still have questions, or you feel the other part uses some techniques that could not be addressed in this review, then you can create a new question for that. \$\endgroup\$ – janos Dec 7 '14 at 15:48
6
\$\begingroup\$

Wow! You put a lot of work into this. Thank you for sharing. I have some suggestions for you to consider.

  1. Add setlocal to the top of your script. This script uses a lot of variables. After you exit, they're still hanging around, junking up your environment, potentially causing problems for other scripts that expect those variables not to be defined. Adding setlocal just below @echo off will narrow the scope of those variables to this script, and the variables will be forgotten on exit (whether the script exits gracefully or not).

  2. Get into the habit whenever you set a variable to a string, to set "var=value" with the var + value pair enclosed in quotation marks. One of these days you may need to capture special characters like & or |, or some XML or HTML to a variable. If you set "var=<xml tags>" you don't have to worry about those special characters getting evaluated unintentionally. Get this habit under your fingers now and you will spend much less time in the future debugging.

    As a pleasant side effect, employing this advice with set /P "var=Enter a choice: " allows you to echo a trailing space after your prompt, which makes text entry a little nicer for the user than your (perhaps overly generous) use of ellipses.

  3. That's a nice thought that you're using braces around each item in some of your if statements, but not terribly effective. If the variable you're testing includes a space, your script will crash. Use quotation marks instead. if "%option%"=="1" for example.

  4. Instead of if %ERRORLEVEL% equ 0 consider using conditional execution with the && and || operators. For example: ver | find "5.0." > nul && goto ver5x.

  5. While we're on the subject of ver | find (or findstr as the case may be), you know you're executing that up to 8 times in a few of your subroutines. A more efficient method would be to set a variable to ver once, then test for substring matches using string substitution.

    Try this:

    for /f "delims=" %%I in ('ver') do set "ver=%%I"
    if "%ver%" neq "%ver:Version 5.=%" goto ver5x
    if "%ver%" neq "%ver:Version 6.=%" goto ver6x
    

    ... etc. The way that works is, if this script is run on an XP box, "Version 5." gets replaced by nothing, so the original %ver% no longer equals the manipulated %ver%; and thus, goto is fired. But on Vista, since %ver% doesn't contain "Version 5.", there's nothing to replace. "%ver%" equ "%ver%", and the script continues to the next line.

    Using the batch language's internal processing is usually faster than calling an executable (unless you're trying to replace sed with a hive of nested for loops or similar, but I digress). Even if the difference is only a couple hundred milliseconds, efficiency is rarely a bad thing.

  6. Search and replace %choice% with %option%. Looks like you changed your mind about the variable name, but didn't get it updated everywhere it needed to be.

  7. Remove the trailing period from %windir%\ie8\spuninst\spuninst.exe.

  8. Since many of the actions offered by this script require elevation to admin privilege, consider having your script prompt for elevation if needed.

Otherwise, the blood, sweat, and tears you have devoted to this project are obvious. I can see this script being useful for many people. Well done, Bobby!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.