NT Syntax : Autoexec commands

To run a command as soon as the command prompt is opened use the registry:

HKLM\Software\Microsoft\Command Processor\AutoRun
HKCU\Software\Microsoft\Command Processor\AutoRun

To run a command as soon as a user logs in - use START-STARTUP or

HKLM\Software\Microsoft\Windows\CurrentVersion\Run
HKCU\Software\Microsoft\Windows\CurrentVersion\Run
HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\Run

To run a command as soon as the machine powers up, like AUTOEXEC.BAT in older operating systems, things get a little more complicated, NT does have an autoexec.bat file but it is only provided for backwards compatibility.

Any SET statement in autoexec.bat will be parsed at boot time,variables set in this way are not available to 32 bit gui programs - they won't appear in the control panel. They will be visible from the CMD prompt.

This behaviour is to allow old DOS applications to install correctly.

If autoexec.bat CALLS any secondary batch files, the additional batch files will NOT be parsed at boot.
This behaviour can be useful on a dual boot PC.

All other commands in autoexec.bat will be ignored.

To configure commands to run at boot up time use the resource kit utility called AUTOEXNT (autoexec for NT) - warning early NT version of this are buggy - make sure you have an up to date copy of the resource kit.

Unzip the file and extract the files autoexnt.exe, autoexnt.bat and servmess.dll to %systemroot%/system32

Also extract the file INSTSRV.EXE to any directory (a temp directory will do) and then at the command prompt enter:

instsrv install

This will create a new service called AutoExNT

Edit the file %systemroot%/system32/AUTOEXNT.BAT and put in the commands to be run when the machine boots. Don't confuse this with autoexec.NT and config.NT - these files are used to configure UMB/EMM for old 16 bit DOS applications and are very rarely if ever required.

* Note: INSTSRV can be used to install/remove device drivers as well. To get a list of all services installed whether disabled, running or stopped look in HKLM\SYSTEM\CurrentControlSet\Services

Related commands
:

SCLIST
- Display NT Services
SET - Display, set, or remove Windows NT environment variables
Q243486 - Run a .bat file before login




Simon Sheppard
SS64.com