Set up NT programs to run automatically

Five years ago, I ran a company with two locations. Each location had a separate cc:Mail post office. The locations exchanged mail through a Lotus dial-up gateway tool, a simple DOS program that dialed in to one post office from another post office and exchanged mail between the two.

At first, I dedicated a DOS machine to the task of exchanging mail. I later tried running the gateway program on a Windows NT machine, hoping that NT would eliminate my need to run the program on a dedicated computer. The gateway worked wonderfully on NT, and it didn't require a dedicated machine. But every time the NT machine rebooted, someone needed to remember to log on to the computer and start the cc:Mail gateway. This necessity was a pain. I needed an autoexec.bat file for NT.

Now, my company uses an NT-based mail product that runs as a service. Services start automatically, so I don't need to manually start the mail exchange program every time I reboot. But I still get letters from systems administrators who need to set up non-service programs to start every time NT powers up.

Microsoft Windows NT Server 4.0 Resource Kit and Microsoft Windows NT Workstation 4.0 Resource Kit offer the tool that I was looking for back in my cc:Mail days: AUTOEXNT. It lets you create an autoexnt.bat batch file and move commands to that file, just as you could do in DOS. After you create the batch file, the AUTOEXNT service runs autoexnt.bat whenever you power up your NT system.

How to Make It Work
Installing AUTOEXNT is simple. Look in the directory in which you installed the resource kit files. Copy the autoexnt.exe and servmess.dll files from that directory into your NT machine's System32 directory. Build a batch file that contains the commands that you want to run automatically when your system boots, name the file autoexnt.bat, and put it in the System32 directory.

Next, install AUTOEXNT as a service. In the resource kit directory, you'll find a program called instexnt.exe. This program tells the Services database to recognize the AUTOEXNT service. To install the AUTOEXNT service, type either

instexnt install


instexnt install /interactive

at a command prompt. Which command you choose affects how AUTOEXNT works.

Interactive AUTOEXNT
You must use the /interactive switch to run programs that need to communicate with the user. If you place a program that requires user interaction (for example, User Manager) into autoexnt.bat and don't use the /interactive switch, the program's windows won't appear. If User Manager's win-dows don't appear, the program is useless. You usually won't have a problem installing programs without the /interactive switch because most of the programs that you'll need to start automatically (such as a mail gateway) don't have an interactive component, just as NT services don't require user interaction.

If you use the /interactive option to install the AUTOEXNT service, you open yourself to interesting logistical and security questions. For example, suppose I put the regedit command into autoexnt.bat. Does the Registry Editor window appear at the initial logon screen, or only after a user logs on? Suppose the first person who logs on to the PC isn't an administrator. What kind of rights would that user have from regedit's point of view? And does regedit appear every time someone logs on, or only when the PC first boots?

My recent AUTOEXNT experimentation demonstrated that if a program you invoke through AUTOEXNT is not interactive, the program starts immediately during the machine's startup and does not wait for anyone to log on. However, interactive programs don't seem to do anything until someone logs on. After a user logs on, the interactive program's window appears. I'm sure NT techies have guessed the answer to the second question: Because AUTOEXNT runs as a service, every program AUTOEXNT starts has the authority of the service's account, which by default is the System Account. Placing regedit in an AUTOEXNT batch file starts an instance of regedit that lets any user who logs on to that machine make unlimited changes to the Registry. You need to think twice about running interactive programs under the AUTOEXNT service. Finally, I discovered that programs in the AUTOEXNT batch file run only when a machine boots, not every time a new user logs on.

AUTOEXNT is a cool tool. I wish I'd had it back in 1993.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.