Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save stanwu/0623a635827db2270f88277c4221aa48 to your computer and use it in GitHub Desktop.
Save stanwu/0623a635827db2270f88277c4221aa48 to your computer and use it in GitHub Desktop.

JSI Tip 0470 - How to launch a program before the shell (Explorer) starts.

Mar 27, 1998 Jerold Schulman In tip 074, I explained how to change the Shell for selected users.

Using the same technique, you can launch an application before the Shell, so as to avoid any interaction with it.

Leaving the Shell as Explorer.exe, edit:

HKEY_LOCAL_MACHINE\Software\Microsoft\WindowsNT\CurrentVersion\Winlogon\Userinit

Double-click Userinit and change the string which begins with USERINIT,NDDEAGNT.EXE..... to YourOwn.exe,NDDEAGNT.EXE..... or YourOwn.bat,NDDEAGNT.EXE.....

Place your EXE or BAT file in the %SystemRoot%\System32 directory.

Since USERINIT is responsible for executing the shell program, you must start it yourself at the end of your program or batch file.

Explorer.exe is the standard shell in Windows NT 4.0. It can operate in either of two modes:

  • Browser mode
  • Shell mode (to manage the desktop, taskbar, and Start button)

When USERINIT launches Explorer.exe, Explorer.exe checks that no instances of Explorer.exe are running and that it is the Shell. If both conditions are true, it starts in shell mode.

Example: (we changed the registry entry to USERINIT.BAT,NDDEAGNT.EXE.....)

@echo off
REM JSI USERINIT.BAT
call %SystemRoot%\System32\DelTemp.bat
%SystemRoot%\System32\Userinit.exe
exit

where %SystemRoot%\System32\DelTemp.bat contains:

@echo off
RD /q /s C:\Temp
MD C:\Temp

Note: Don't use an Exit command in any called batch file.

Your EXE or BAT file will execute without any interaction with the Shell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment