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 offREM The above command turns off the output for the scriptREM Name : logoff.batREM Author : Craig RichardsREM Created : 15th-April-2011REM Version : 1.2REM 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 machineREM Instructions : From the command line, just type logoff.bat, or double click on the file in windows explorerREM Clear all Temporary Internet FilesRunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8REM Clear IE HistoryRunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1REM Remove all files from %TEMP% - You can get a copy of sdelete here http://technet.microsoft.com/en-us/sysinternals/bb897443sdelete -s %TEMP%/*.*REM Remove list of Recently opened documents - You can get a copy of sdelete here http://technet.microsoft.com/en-us/sysinternals/bb897443sdelete "%USERPROFILE%\Recent\*.*"REM Compress the days puttylogs - 1.2python puttylogs.pyREM Log the date/timeecho %DATE% %TIME% >> %HOMEDRIVE%\logoff.txtREM Log off my machineshutdown -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.
This is the python script I wrote to zip up my puttylogs.
# Script Name : puttylogs.py
# Author : Craig Richards
# Created : 13th October 2011
# Last Modified :
# Version : 1.1
# Modifications : 1.1 - Added the variable zip_program so you can set it for the zip program on whichever OS, so to run on a different OS just change the locations of these two variables.
# Description : Zip up all the logs in the given directory
import os # Load the Library Module
import shutil # Load the Library Module
from time import strftime # Load just the strftime Module from Time
logsdir="c:\logs\puttylogs" # Set the Variable logsdir
zip_program="zip.exe" # Set the Variable zip_program - 1.1
for files in os.listdir(logsdir): # Find all the files in the directory
if files.endswith(".log"): # Check to ensure the files in the directory end in .log
files1=files+"."+strftime("%Y-%m-%d")+".zip" # Create the Variable files1, this is the files in the directory, then we add a suffix with the date and the zip extension
os.chdir(logsdir) # Change directory to the logsdir
os.system(zip_program + " " + files1 +" "+ files) # Zip the logs into dated zip files for each server. - 1.1
os.remove(files) # Remove the original log files
I have just changed this script slightly now that I have upgraded my work machine to run Windows 7 Professional. The location for the recently opened files has now changed.
On Windows XP they used to be stored
Now I am Windows 7 Professional, the new location is