Borland Online And The Cobb Group Present:


September, 1995 - Vol. 2 No. 9

WinRun's Command-Line Options

In the accompanying article, Running multiple versions of Borland C++ using WinRun, we show how you can force WinRun to launch a Windows application from a batch file synchronously (meaning the batch file will pause until the Windows application exits).

However, WinRun's default settings are set to run batch files asynchronously (meaning the batch file won't wait until the Windows application exits to run). Here, we'll explain the command-line options for WinRun that affect how it runs Windows applications from a DOS prompt under Windows.

WinRun or WR.EXE?

There are actually two executable programs that make up the WinRun utility: WINRUN.EXE and WR.EXE. WINRUN.EXE, or WinRun, is a Windows application that ships with Borland C++ and that can actually launch other Windows applications. WR.EXE is a DOS application that helps WinRun launch Windows programs under special circumstances.

WinRun

The Borland C++ 4.5 installation program automatically places a program item for WinRun in your system's StartUp folder. If you've seen this icon on your Windows desktop and tried to activate it, you may have noticed that the program doesn't have a main window, just a pop-up menu for the icon. From the pop-up menu, there are two options, Auto Detect and Async Exec, as shown in Figure A.


Figure A - You can use the WinRun pop-up menu to change the basic WinRun options.

In this menu, WinRun displays a check mark next to the options that are enabled. If you enable the Auto Detect mode, WinRun will test every application you try to launch from a command line to see whether it's a Windows application or a DOS application.

If you disable the Auto Detect mode, you'll have to invoke WinRun manually using WR.EXE. (We'll discuss this option in a moment.) Since WinRun will cause DOS applications to launch a little more slowly than they normally would, you may want to leave the Auto Detect mode disabled, which is its default state.

If you enable the other option, Async Exec, WinRun won't suspend the DOS command line or batch file while it runs the Windows application. Instead, the command line or batch file will resume as soon as you make it the foreground process (by switching to that window or full-screen session). If you disable the Async Exec option, WinRun will suspend the command line or batch file until you exit the Windows application.

WR.EXE

As we mentioned earlier, WR.EXE is a DOS program that allows you to invoke a Windows program manually by using WinRun, if WinRun is already running. Using WR.EXE, you can force WinRun to launch a Windows application even if you've disabled the Auto Detect mode of WinRun.

In addition, WR.EXE accepts -w and -a as command-line parameters. Adding -w to the command line forces WinRun to launch the Windows application synchronously (which corresponds to wait mode). If you add -a to the command line, WinRun will launch the application asynchronously.

To launch WRITE.EXE from a command line and suspend the command line until WRITE.EXE exits, enter

wr -w write

When you exit WRITE.EXE, the command line will again be available. Similarly, if you add this command to a batch file, as we show in the accompanying article, WinRun will suspend the execution of the batch file until you've exited the WRITE.EXE program.

Running Windows applications using WR.EXE is different from allowing WinRun to automatically detect when a program is a Windows program. As we mentioned before, using WinRun's Auto Detect feature will cause it to slow the launching of normal DOS programs while it checks to see if they're Windows programs. To avoid this slowdown, you can simply use WR.EXE, as we've shown here, to launch Windows programs.

Return to the Borland C++ Developer's Journal index

Subscribe to the Borland C++ Developer's Journal


Copyright (c) 1996 The Cobb Group, a division of Ziff-Davis Publishing Company. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of Ziff-Davis Publishing Company is prohibited. The Cobb Group and The Cobb Group logo are trademarks of Ziff-Davis Publishing Company.