Subscribe to Windows IT Pro

 

Get Newsletters

  • Get the Latest News
  • Product Updates
  • Helpful Tricks
  • Productivity Tips

Subscribe Now!

July 28, 2008 12:00 AM

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

Achieve small-scale software deployment without errors or omissions
Windows IT Pro
InstantDoc ID #99528
Rating: (3)

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

Related Content:

ARTICLE TOOLS

Comments
  • Caroline
    4 years ago
    Aug 04, 2008

    @glenmcl--it's loaded now. You can click the sidebar link beneath the title above or go to this URL:
    http://windowsitpro.com/articles/articleid/99675/Use_Batch_Files_to_Automate_Application_Installation.html

  • Caroline
    4 years ago
    Aug 01, 2008

    It is being loaded August 1 or August 4. I hope you'll look again and let us know your thoughts about the articles!
    Caroline Marwitz

  • Glen
    4 years ago
    Jul 30, 2008

    The printed article contains an author's note that there is a simpler method that he has since crafted which is discussed in InstantDoc ID 99675. That doc does not seem to exist?

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

White Papers

Get your Windows 7 deployment off to the right start by implementing PC lockdown. A locked-down environment is easier and cheaper to support since users are less likely to make unnecessary changes to the core system configuration - read more here!

Essential Guides

Is your iSCSI "lossy"? The reality is that most off-the-shelf Ethernet hardware deployed for iSCSI can lose packets, resulting in slow performance or application downtime. Learn how to assess your current iSCSI infrastructure and engineer an advanced iSCSI SAN infrastructure.

Web Seminars

What's the best way to keep your network safe from malware? In this web seminar, security expert Greg Shields suggests an alternative method to the traditional blacklisting approach that is common with anti-virus and anti-malware solutions.

eLearning Series

We bring the experts direct to you to share their real-world perspective and expertise. During each event, three sessions stream in real time, so you can learn, ask questions, and get solutions.
Upcoming event: Getting the Most with Exchange 2010 with Paul Robichaux

Subscribe to Windows IT Pro!

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.