Couple of years ago, we had a problem with custom software. The problem was, how to install new version of software (size around 60MB+), only on main computers in our branch offices, which are over 60 locations. Since we don’t have in house programmer, we needed a solution. Solution by now, was connecting to remote computers (our VPN is on ADSL) over ADSL modem, configured to port-forward PcAnywhere. Then copy new version to that computer, unpack, change config file, and deploy. Three men, have been doing this for 5 days.
We (meaning I) needed a solution, to make this less time consuming and less repetitive.
I sat down, and came up with the solution. Semi-automated batch script. The only thing that the person in office would do is, start batch, and press corresponding number (1-proceed,2-Cancel).
So, here is a little demo.
You start by using echo command like this, but must disable “echo” to print with “@echo off”
Then we needed a blank Main Screen. CLS is command to ClearScreen.
Click on picture to open SkyDrive with this file.
So we have small sample of batch file. Now we have to crate a shared folder, somewhere on the VPN, where all users can reach this batch.
And in the end, set shortcuts (you can do that via logon script) to users desktop.
This is simple batch file for copy numerous things to computers around you. But there is one more thing I needed to do.
How to change config file, insert new parameters or change the existing ones.
Prepare to be amazed 🙂
Changing a string in config file:
For this I came across a little exe called change.exe (file is here).
Lets say you need to change PARAM1=OFF to PARAM1=ON.
The syntax is
CHANGE.EXE [filename] “what to change” “change to”
CHANGE.EXE config.ini “PARAM1=OFF” “PARAM1=ON”
Problem with CHANGE.EXE is that this file does not work in 64bit environment.
Adding or removing text from config file:
Lets say you have to put another parameter PARAM4=OFF (or multiple) into end of config file.
Create a file PARAM4.txt
Make a batch with statement:
find /v “[EOF]” < config.ini> config.ini.temp
//find [EOF] in config.ini and everything above it save to config.ini.temp
copy/b config.ini.temp+param4.txt config.ini.new
//now combine config.ini.temp and pram4.txt into new file config.ini.new
copy/b config.ini.new config.ini
//now overrun config.ini with config.ini.new
Lets say you have to remove PARAM2=OFF, then you need only two lines from above:
find /v “PARAM2=OFF” < config.ini> config.ini.temp
//find PARAM2 in config.ini and everything else save to config.ini.temp
copy/b config.ini.temp config.ini
//now overrun config.ini with config.ini.temp
So, this should cover small portion of batch procedures.
Till next time…