The Technofile Web site has moved.

Technofile is now located at
Please update your links, bookmarks and Favorites.  

Yes, Windows is Dumb: Microsoft's WINSET program lets DOS programs communicate

technofile  by al fasoldt

Columns and commentaries in a life-long dance with technology

Simple gray rule

Excerpted from
Yes, Windows Is Dumb
Easy Ways to Master Your PC
Copyright © 1997-1998, Al Fasoldt


Microsoft's little-known WINSET program lets DOS programs communicate with each other

By Al Fasoldt

Copyright © 1998, Al Fasoldt

Windows has a global environment, a space in memory where information is stored. The neat thing about the global environment is that all programs can look there to find such things as the PATH. The non-neat thing is that DOS programs get a copy of the original global environment and nothing more. If the environment changes, DOS programs haven't a clue. When you open a DOS window or run a DOS program directly, it inherits a copy of the global environment that was set when the PC booted up.

DOS can change its copy of the environment, of course. Open a DOS window and type SET MYNAME=GEORGE and DOS will assign the variable MYNAME to the value GEORGE. As far as Windows is concerned, there is no such variable as MYNAME. Even worse, you can run another instance of DOS and it, too, will have no idea that MYNAME exists.

This problem can be circumvented in various ways. You could create a control file when you run a DOS program and name the file MYNAME.VAR. Another instance of DOS could look for a .VAR file and try to pick up the name and therefore the variable. (Other ways have been documented innumerably in books on DOS; we'll skip all of them here. They are all kludges.)

Luckily, Microsoft has given you a way out. You have a file on the Windows setup CD that lets DOS programs alter the global environment at any time. It's called WINSET. Just search for it using the Start Menu's Find function and you'll locate it right away. Copy it and the text documentation to the C:\Windows\Command folder. (Note: Right drag the two icons and let go over the Windows\Command folder, then choose to make a copy. Don't make shortcuts.)

What does WINSET do? It merely works the way the SET command operates, except that it alters the environment that DOS programs (and, of course, Windows programs) see when they start up. Listen up, because the next part should mean a lot to you if you work with batch files. WINSET allows one batch file to talk to other ones, to tell them that something has changed, for example. This can keep batch files (and the programs they run—both DOS and Windows programs) from misbehaving.

Let me give you an example. Suppose you'd like to launch two of your favorite Internet programs by means of a timer or by another sort of automated method. Obviously, you don't want them to run if they are already running. (Some Windows programs won't let Windows start another instance, but others will. The point is that you'd want to control whether programs that are already running are skipped by the automatic-run method, right?)

WINSET provides an easy way. WINSET is a so-called console program (a fancy name for what looks like a DOS program but is really a Windows command-line application). It can be run from the DOS command line, from a batch file or from Windows itself. The easiest way to use it is from a batch file.

Here's a batch file that runs Microsoft Outlook 97, Microsoft Internet Explorer and a freeware clock-setter, AtomTime. I call it NETSTART.BAT. I designed it to be launched by a scheduler. Because I have only indirect control over what programs the scheduler launches (that's the point, after all—it does the launching on its own), I needed a way to tell the batch file whether I've already started Outlook and Internet Explorer. (The time-setter can be run repeatedly; it's just a tiny program.)

By using WINSET, this batch file is able to do all that. Here it is:

@echo off

if %1()==() goto begin

if %1==/? goto help

if %1==? goto help

if %1==help goto help


if %outlook%==yes goto outlskip

winset outlook=yes

start "C:\Program Files\Microsoft Office\Office\OUTLOOK.EXE"


if %ie%==yes goto ieskip

winset ie=yes

start "C:\Program Files\Internet Explorer\IEXPLORE.EXE"


start C:\APPS\Sysutils\ATOMTIME.EXE autoUpdate

goto end


echo NETSTART.BAT by Al Fasoldt.

echo. Starts apps listed in the batch file

echo. only if they are not already running.


When NETSTART.BAT runs, it checks to see if the user asked for help (by typing something like "NETSTART /?") and, if that's not the case, checks the global variable named OUTLOOK. If that variable has been set to YES, the batch file skips down to a label so that it won't run Outlook again. If the variable is not set to YES, the batch file sets it to YES and runs Outlook. The same kind of checking goes on in the next section for Internet Explorer.

Feel free to steal the code in this batch file for your own use. There's nothing unique in it. I didn't invent any of the techniques; I just put them together in a way that others may not have considered.

 Image courtesy of Adobe Systems Inc.technofile: [Articles] [Home page] [Comments:]