Useful Windows batch scripts
https://haxordoubt.blogspot.com/2012/09/useful-windows-batch-scripts.html
Batch files are a very efficient way to accomplish multiple tasks quickly. Here, we have compiled a few useful Batch Scripts for use from within the Windows environment (MS-DOS).
KillAll
Here is one of our favorites called KillAll. Once the batch file is executed, all you need to do is type the wordkillall
followed by the workstation id(s) you want to reset (e.g.: killall 17 18 19 31
). This works great if you need to log multiple users off a network at the same time.Directions:
(1.) Open Notepad (notepad.exe)
(2.) Next, Copy and paste the following code into Notepad:
Copy con killall.bat
@echo off
cls
:killanother
if <%1>==<> goto alldead
reset winsta /v %1
shift
goto killanother
:alldead
@echo off
cls
:killanother
if <%1>==<> goto alldead
reset winsta /v %1
shift
goto killanother
:alldead
(3.) Now, save this file as killall, with .bat at the end of it (e.g.: “killall.bat”).
(4.) Double-click your new file to Execute.
Delete IE History with Options
Here is another useful bacth file for quickly cleaning IE History with options. If you work on alot of PC’s, this is a handy batch file to have on a USB drive, or other removable media.Directions:
(1.) Open Notepad (notepad.exe)
(2.) Next, Copy and paste the following code into Notepad:
@Echo off
Set name=%username%
:top
Echo *************************************************************************
Echo * This script will Delete your IE browser history, Chose carefully. *
Echo *************************************************************************
Echo To chose what you would like to delete, select the numbers below.
Echo 1::::::Deletes %name%’s browser history (list of visited sites).
Echo 2::::::Deletes all cookies for username:%name%.
Echo 8::::::Deletes temporary internet files (cache).
Echo 16:::::Deletes all saved forms data.
Echo 32:::::Deletes all saved passwords.
Echo 255::::Deletes all of the above.
Echo 4351:::Deletes all of the above and all settings stored by add-ons.
Echo Which number do you chose:
Set /p num=
If %num% == 1 (RUNDLL32.EXE inetcpl.cpl,ClearMyTracksByProcess 1 && GOTO Done)
if %num% == 2 (RUNDLL32.EXE inetcpl.cpl,ClearMyTracksByProcess 2 && GOTO Done)
if %num% == 8 (RUNDLL32.EXE inetcpl.cpl,ClearMyTracksByProcess 8 && GOTO Done)
if %num% == 16 (RUNDLL32.EXE inetcpl.cpl,ClearMyTracksByProcess 16 && GOTO Done)
if %num% == 32 (RUNDLL32.EXE inetcpl.cpl,ClearMyTracksByProcess 32 && GOTO Done)
if %num% == 255 (RUNDLL32.EXE inetcpl.cpl,ClearMyTracksByProcess 255 && GOTO Done)
if %num% == 4351 (RUNDLL32.EXE inetcpl.cpl,ClearMyTracksByProcess 4351 && GOTO Done) else GOTO Error
:Done
Echo Deleting Internet Explorer files using selection %num%. && pause && exit
:Error
cls && Echo The number you chose does not exist, try again.
GOTO top
Set name=%username%
:top
Echo *************************************************************************
Echo * This script will Delete your IE browser history, Chose carefully. *
Echo *************************************************************************
Echo To chose what you would like to delete, select the numbers below.
Echo 1::::::Deletes %name%’s browser history (list of visited sites).
Echo 2::::::Deletes all cookies for username:%name%.
Echo 8::::::Deletes temporary internet files (cache).
Echo 16:::::Deletes all saved forms data.
Echo 32:::::Deletes all saved passwords.
Echo 255::::Deletes all of the above.
Echo 4351:::Deletes all of the above and all settings stored by add-ons.
Echo Which number do you chose:
Set /p num=
If %num% == 1 (RUNDLL32.EXE inetcpl.cpl,ClearMyTracksByProcess 1 && GOTO Done)
if %num% == 2 (RUNDLL32.EXE inetcpl.cpl,ClearMyTracksByProcess 2 && GOTO Done)
if %num% == 8 (RUNDLL32.EXE inetcpl.cpl,ClearMyTracksByProcess 8 && GOTO Done)
if %num% == 16 (RUNDLL32.EXE inetcpl.cpl,ClearMyTracksByProcess 16 && GOTO Done)
if %num% == 32 (RUNDLL32.EXE inetcpl.cpl,ClearMyTracksByProcess 32 && GOTO Done)
if %num% == 255 (RUNDLL32.EXE inetcpl.cpl,ClearMyTracksByProcess 255 && GOTO Done)
if %num% == 4351 (RUNDLL32.EXE inetcpl.cpl,ClearMyTracksByProcess 4351 && GOTO Done) else GOTO Error
:Done
Echo Deleting Internet Explorer files using selection %num%. && pause && exit
:Error
cls && Echo The number you chose does not exist, try again.
GOTO top
(3.) Now, save this file as ieclean, with .bat at the end of it (e.g.: “ieclean.bat”).
(4.) Double-click your new file to Execute.