A little scripting goes a long way

We’re upgrading the Kaspersky network agent at my workplace today, starting off with 50 machines on two clusters as a trial.

This included a few steps as explained below:

  • disabling a running service
  • configuring the service to  start manually
  • changing the power options to stop the machine powering off after 15 mins of inactivity
  • copying a text file to the root of C: drive
  • running setup.exe (a silent install)
  • restarting the machine

This may not seem like a lot of work but I did have 50 machines to repeat this on, and maybe more with the possibility of extending the trial to more machines. So I came up with a quick batch script to do the job for me. Nothing fancy, just a simple little script:

@echo off 
title KAV Update 
cls 
echo. 
echo Disabling PowerMAN service 
net stop PowerMAN 
sc config PowerMAN start= demand 
echo. 
echo Changing power options... done 
powercfg -change "Student Policy - Office" -disk-timeout-ac 0 
echo. 
echo Copying noklmover.txt to the C: drive... 
copy \\server\share\noklmover.txt c:\noklmover.txt 
echo. 
echo Installing new Kaspersky agent setup file... 
pause 
start /wait \\server\share\setup.exe 
echo. 
echo ...Installation complete 
echo. 
echo Task complete on this machine. Restart? 
pause 
shutdown -r -f -t 15

Writing a quick script is a neat way to automate and relieve yourself from a repetitive task a little quicker than doing it manually. I find it very satisfying when I write a script that ‘just works’. The above script is no more than a simple set of instructions but I reckon I have a good aptitude for programming  in general and with a keen interest in scripting I would love to extend to Windows PowerShell one day.

Speaking of which, that ‘one day’ may be coming a lot sooner since I’m about to start studying for the 70-640 exam (Configuring Windows Server 2008 Active Directory). That reminds me, I’ve still got to write a post on my study plans (and more).

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s