Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 


August 2008

Use Cmd.exe's Start Command to Simplify Setup Automation

Achieve small-scale software deployment without errors or omissions
RSS
Subscribe to Windows IT Pro | See More Windows OSs Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!
SideBar    Use Batch Files to Automate Application Installation

Many organizations are too small to cost-effectively deploy software by using tools such as Microsoft Systems Management Server (SMS). The person responsible for software installation—typically an external IT consultant or an employee with part-time support duties—falls back on manually installing each application on system rebuilds or new installations, which can be a slow and potentially error-prone process. However, by using a simple batch file and cmd.exe’s Start command, it’s possible to speed up the deployment process and reduce the risk of accidental omissions. Let’s look at when and why you’d want to use this method, then walk through how to deal with some of the problems you might encounter.

Why Start?
Cmd.exe’s Start command is a simple tool with features that make it ideal for basic setup automation. In general, any command you can run on a Windows system can be run from a batch file. You can add command-line options as necessary, and the batch file can wait for each command to finish before running the next command.

Why use Start? It’s easy to forget specific applications that you need to install for a system. For example, you might forget to install a small application even though it’s important to a client. At small sites that you rarely visit, you might get distracted by troubleshooting tasks in the middle of configuring a system and forget where you are in a chain of application installations. By wrapping all of the setup launchers into a batch file, there’s no danger of forgetting an application. If you don’t need to install a particular application in the set, you can always cancel its installation and go on to the next one.

It’s also easy to lose specific application sources that are on a network. Again, a batch file will have all of these locations in it, eliminating the headache of searching for those items.

Finally, even when you do know where everything is, you can waste a significant amount of time navigating to files and waiting for applications to start up and shut down. The Start command will shave off some of this start-up time. And when applications have installers that support command-line automation, installation can even proceed while you’re doing other work elsewhere. Let’s look at the proper way to run setups now.

Use the Wait Option
By default, the Start command always spawns an application in a new process and continues on its way. Obviously, it’s not a good idea to start up 17 different installers simultaneously; the resource demand would overload almost any PC. In any case, well-behaved Windows Installer (.msi)–based installation programs will refuse to run if another .msi-based installation is already running, making it easier for Windows to untangle applications. To handle this situation, simply include the /wait option with the Start command. You can abbreviate the /wait option to /w. To run the installer located at z:\dsp xp\WindowsXP-KB926139-x86-ENU.exe, you would start it like this:

start /w z:\dsp\xp\WindowsXP-KB926139
  -x86-ENU.exe
The batch file waits until WindowsXPKB926139- x86-ENU.exe terminates and only then goes to the next command. Occasionally some applications—usually very old ones—run a chain of their own application installations and exit before processes they’ve launched actually terminate. You’re unlikely to run into these older applications very often, but if you do, you can still use the batch file after adopting one of two strategies. Either place a single such application at the very end of the batch file, where it won’t matter that the /wait does you no good, or insert a Pause command in the batch file immediately after the line on which you run the installer:

start z:\dsp\legacy\oldapp.exe
echo wait for OldApp to finish
  installing && pause

Although it theoretically doesn’t help in this situation to use the /w option, it’s a good habit to use in creating scripts for setup chaining.

Set the Working Directory
On some occasions, you might need to control the working directory of the launched application. For example, some installers might use user-specific license files or need a local directory for extraction and not automatically get the user’s temp folder. You can force the working directory by using the /d option. If the application needs files from the OldAppData folder in the user’s profile, you can run it like this:

start /w /d %userprofile%\OldAppData
  z:\dsp\legacy\oldapp.exe

Handling Paths with Spaces
The single most significant problem people encounter when using the Start command is its behavior with file paths containing spaces. If you check the command-line options for the Start command, you’ll see why. Omitting some of the options for brevity, the Help display looks like this:

START ["title"] ... [command/program]

When the Start command sees a quoted string in its command line, Start assumes that you want to create a new window with the quoted string as the title. This means that if you try to run the installer z:\dsp\misc\Acme Shipping.msi by using the command

start /w "z:\dsp\misc\Acme Shipping.exe"

you won’t see the Acme Shipping.exe installer start. Instead, an empty command-prompt window will pop up with the title z:\dsp misc\Acme Shipping.exe.

Continue to page 2

   Previous  [1]  2  Next 


Top Viewed ArticlesView all articles
2009 Windows IT Pro Editors' Best and Community Choice Awards

Picking a favorite product from an impressive crowd of competitive offerings is never an easy task, and such was the case with our Editors' Best and Community Choice awards this year. ...

Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

WinInfo Short Takes: Week of November 23, 2009

An often irreverent look at some of the week's other news, including some post-PDC some soul searching, a Google Chrome OS announcement and a Microsoft response, Windows 7 off to a supposedly strong start, the Jonas Brothers and Xbox 360, and so much more ...


Related Events Deep Dive into Windows Server 2008 R2 presented by John Savill

Check out our list of Free Email Newsletters!

Windows OSs eBooks Understanding and Leveraging Code Signing Technologies

A Guide to Windows Certification and Public Keys

SQL Server Administration for Oracle DBAs

Related Windows OSs Resources Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2009 Penton Media, Inc. Terms of Use | Privacy Statement