Home NT NT Syntax

NT Syntax : Autoexec commands

To run a command as soon as the command prompt is opened -

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

To run a command as soon as a user logs in -

The STARTUP folder (Start Menu)
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 MS-DOS), 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, but the variables set in this way are not available to 32 bit gui programs - they will be visible from the CMD prompt but won't appear in the control panel. All other commands in autoexec.bat will be ignored.

This behaviour is to allow old DOS applications to install correctly. It's worth noting that if autoexec.bat CALLs a second batch file, the additional batch file will be completely ignored by NT.

AutoExNT

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

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.

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