Network Administrator Knowledgebase

Nov 14 2007   3:40PM GMT

Free Deployment System

Michael Khanin Michael Khanin Profile: Michael Khanin

All Network Administrators at least once thought about how to install a program on remote computer without ever touching it. Hopefully, today we have a lot of ways to achieve this goal. The very interesting part of it all is, when ever I provide a consulting services to companies, I hear the same question, “Michael, do you know any FREE solutions to distribute programs, patches or run anything on remote computers?

I’d like to show you the solution, I’ve created for myself. Let’s call it “Free Deployment System :)”…

Free Deployment System” contains a set of scripts and free tools. The heart of this system is a PSExec by Sysinternals.

Before I start, let’s clarify few pre-requirements. We need one server or computer that will hold off packages and scripts. The Deployment System will run on this system. We need a user with administration privileges on all remote computers (We can create a user on Domain level and set the necessary permissions to this user).

Ok, now we are ready to start.

Let’s created a directory structure on deployment server.


In my situation, I don’t have any files in C:\Operation directory. In C:\Operation\Tools directory I have tools that I have been using in my scripts. The main scripts of “Free Deployment System” are located in C:\Operation\Scripts. C:\Operation\Packages contains packages for remote installation. Set a Share on the C:\Operation\Packages and give all users Read Permissions.Now we need to create a few files in C:\Operation\Scripts directory. The first file is #Servers.txt. This file contains an IP addresses or Computer Name of remote computers. Each IP or name should be on new line. In my case #Servers.txt looks as follow:

The next file in our system will be a Config.bat. By using Config.bat I set credentials for connection to remote computers. Config.bat looks as follow:

@echo off
set DM=AdminInfo
set PASS=TSAPassWord

OK, now we are going to create a main script of our system. I named it INSPKG.bat, meaning “Install Packages”. Before show the content of INSPKG.bat I’d like to say a few words about how it works.

INSPKG.bat runs in loop and checks each line of #Servers.txt file and use this addresses as a destination where the installation package should be installed. When the package installed on last computer (last line in #Servers.txt file) INSPKG.bat will stop working. If you have too many computers in your network, the package deployment could take time, be patient. So, INSPKG.bat contains the following lines:

@echo off

Rem *****************************************************************************
Rem *       For 1 envirement use the Pakage file name                           *
Rem *       The general location of all Pakage is: C:\Operation\Packages        *
Rem *       On remote computer computer should be located  "C:\Updates"         *
Rem *                                                                           *
Rem *       Websites:                        *
Rem *                                                                           *
Rem *****************************************************************************

if {%1}=={} @Echo Please set the Pakagename.The format is INSPKG.bat 7Zip &goto :EOF

set Scripts=C:\Operation\Scripts
set Tools=C:\Operation\Tools
set Packages=C:\Operation\Packages

call %Scripts%\Config.bat

SET LoopNum=
SET Line=
SET Line=0

TYPE %Scripts%\#Servers.txt > %TEMP%\SRVLIST.txt

FOR /F "TOKENS=*" %%a in ('%Tools%\LINEX -c ^<%TEMP%\SRVLIST.txt') do set IP-SRV=%%a
SET /a LoopNum=%IP-SRV% + 1

SET /a I=%I% + 1
SET /a Line=%Line% + 1
IF "%I%"=="%LoopNum%" goto END
FOR /F "TOKENS=*" %%a in ('%Tools%\LINEX -l %Line% ^<%TEMP%\SRVLIST.txt') do set RCOMP=%%a

copy "%Packages%\%1\%1.bat"  "\\%RCOMP%\c$\Updates\" /Y

@echo Please wait ...

%Tools%\psexec.exe \\%RCOMP% -u %DM%\%USR% -p %PASS% -i C:\Updates\%1.bat

SET Line=%Line%
goto LOOP1

SET LoopNum=
SET Line=
SET Line=

INSPKG.bat should run from a console (cmd.exe) of our deployment server. The format is following:

C:\Operation\Scripts\INSPKG.bat 7Zip

Where, 7Zip is a name of a package. As you can see, in this example, I’m going to deploy a 7-Zip to all computers, but before this I have to create a package. So, for this purpose I’m going to the C:\Operation\Packages directory and create a new directory, 7ZIP. Inside 7ZIP I create a file 7ZIP.bat and put the installation file of 7-Zip. I’m going to install a 7z442.exe on all computers. By using RTFM rule :), I know that to install a 7-Zip in silent mode I have to use switch /S. So, my 7Zip.bat contains the following lines:

@echo off
\\\packages\7ZIP\7z442.exe /S

Note: Change to the IP or name of your Deployment Server.

And, on the final, we need put necessary tools to the C:\Operation\Tools directory. Download last version of PSExec and put it to C:\Operation\Tools directory. In INSPKG.bat I’m using a very cool tool, LINEX.EXE. Linex.exe is a part of “Bill Stewart’s freeware Batch Script Tools”. When I wrote this article, I tried to find an official web site of “Bill Stewart’s freeware Batch Script Tools”, but failed. So, you can download a Linex.exe directly from my web site.As additional example, I’ve created packages for Acrobat Reader and Firefox.  Keep in mind to create a separate directory for each package. The Directory and name of package script should be the same, meaning if you are going to create a package for Firefox inside C:\Operation\Packages create directory Firefox and inside C:\Operation\Packages\Firefox create a script Firefox.bat and also inside C:\Operation\Packages\Firefox put the installation file of Firefox. Here is my Firefox.bat:

@echo off
\\\packages\Firefox\FirefoxSetup2.0.0.9.exe -ms 

Note: Change to the IP or name of your Deployment Server.

I hope I didn’t forgot anything 🙂 .
Let me know what kind of package you are interesting in and I’ll try to create it. I’ll be very happy if you write comment for this article.

1  Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.
  • SoniAnkitK
    Thanks for sharing such wonderful script, I tried using you script but it seems to be failing at below command. TYPE %Scripts%#Servers.txt > %TEMP%SRVLIST.txt Also INSPKG Seems to have blank variables set as below. SET IP-SRV= SET LoopNum= SET Line= SET I= SET RCOMP= SET Line=0 Would be great if you could clarify the above queries. I Get the below error. C:OperationScripts>TYPE C:OperationScripts#Servers.txt 1>C:UsersUserAp pDataLocalTempSRVLIST.txt The system cannot find the file specified.
    0 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: