Friday, March 30, 2012

Windows Batch File to Overcome Repeating Tasks

Every time we work on any project we need to open putty, winscp3 along with multiple folders, documents and web-pages. I do this every time I start working on the project, so to simplify a bit I tried something with batch files to make it easier to open related things for a project in one go. This sample file will
1) open the putty and login into it automatically.
2) open the winscp3 and login into it automatically.
3) open webpages,, and
4) open this document D:\Documents and Settings\avatsyay\My Documents\R&A\MigratingToJboss6\DeploymentOnJboss6.doc
5) open folder My Docuemnts and Eclipe

Here is the sample batch file

@echo off
set ProgRoot32=%ProgramFiles%
set ProgRoot64=%ProgramFiles%

if not "%ProgramFiles(x86)%" == "" set ProgRoot32=%ProgramFiles(x86)%

REM Start an File Explorer that stays inside the specified folder.
REM Remove the /ROOT parameter (leave the comma) to disable folder lock.
%SystemRoot%\explorer.exe /ROOT, C:\jboss-6.1.0.Final\server\default\log\

REM Start a 32-bit application. Replace with %ProgRoot64% if running 64-bit app.

REM Open a few applications
start "Putty" "D:\Documents and Settings\avatsyay\My Documents\Softwares\putty.exe" -ssh change_myuser@172.x.x.x -pw change_mypassword
start "WinSCP3" "C:\Program Files\WinSCP3\WinSCP3.exe" change_WinscpSavedSessionName
start "Eclipse" "C:\eclipse_helius\eclipse.exe" -data "D:\Documents and Settings\avatsyay\workspace"

REM Open a couple webpages
start "My Alcatel Lucent" ""
start "My Google" ""
start "MY Light Reading" ""

REM Open a document (simulates a double-click)
start "My Document" "D:\Documents and Settings\avatsyay\change_Mydoc.doc"
One more use I'll put this file to: opening all the things which I need on system startup. This can also be done by keeping all this in windows startup script but I see a benefit: In weekdays it won't start unless I double click that script ;)

Don’t forget to modify the document, folder and login details accordingly (highlighted in the above sample)


No comments:

Post a Comment