Powered by Squarespace

Get yourself extra space on Dropbox

 

Entries in batch (1)

Tuesday
Oct182011

Windows logoff script (logoff.bat)

This is just a quick post to let you see a simple batch script I have written that I run everytime I log out of my work PC.  It's very simple, just cleans up a few things, the script is fully documented, but if anything isn't clear then please feel free to ask.

There a python script that is called, this is a new addition which goes through and compresses all of my putty session logs, I have a seperate log for each of my PuTTY server connections, depending on what I am doing they can grow quite large, so the script compresses and date stamps them.  I can post the python script if you would like to see it.

You can download the batch file here.

 

@echo off
REM The above command turns off the output for the script
REM Name : logoff.bat
REM Author : Craig Richards
REM Created : 15th-April-2011
REM Version : 1.2
REM Modified : 1.1 - Changed hard coded path from C:\Documents and Settings\my name to %USERPROFILE%
REM : 1.1 - Changed the hard coded path for drive to %HOMEDRIVE%
REM : 1.2 - Added the section to call my python script to compress my puttylogs when I log off the machine
REM Instructions : From the command line, just type logoff.bat, or double click on the file in windows explorer
REM Clear all Temporary Internet Files
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8
REM Clear IE History
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1
REM Remove all files from %TEMP% - You can get a copy of sdelete here http://technet.microsoft.com/en-us/sysinternals/bb897443
sdelete -s %TEMP%/*.*
REM Remove list of Recently opened documents - You can get a copy of sdelete here http://technet.microsoft.com/en-us/sysinternals/bb897443
sdelete "%USERPROFILE%\Recent\*.*"
REM Compress the days puttylogs - 1.2 
python puttylogs.py
REM Log the date/time 
echo %DATE% %TIME% >> %HOMEDRIVE%\logoff.txt
REM Log off my machine
shutdown -l -f 

 

As always I am always interested in your thoughts so if you have any comments or feedback then please feel free to add any comments, or you can mail me  here.