RUNDLL

 

RUNDLL and RUNDLL32 are two utilities supplied with Windows 95/98 and NT.
They can call DLL functions from the command line, allowing us to create extremely powerfull batch files.

Some examples:

  1. Start Control Panel applets (2):
  2. Install a screensaver (copy the *.SCR file to the Windows directory first) (2):
    RUNDLL32 DESK.CPL,InstallScreenSaver C:\WINNT\SYSTEM32\Default.scr
    
    The directory shown is for Windows NT, adjust for Windows 95/98
     
  3. Start "Add New Printer" wizard:
    RUNDLL32 SHELL32.DLL,SHHelpShortcuts_RunDLL AddPrinter
    
  4. Start GUI diskette format program:
    RUNDLL32 SHELL32.DLL,SHFormatDrive
    
  5. Logoff Windows (1)
  6. Reboot (1)
  7. Shutdown (1)
  8. Show Windows 9*'s "System setting changed, do you want to reboot now?" dialog (1):
    RUNDLL SHELL.DLL,RestartDialog
    
  9. Display NT's "About" dialog, showing version, servicepack, registered owner and amount of physical memory:
    RUNDLL32 SHELL32.DLL,ShellAboutW
    
  10. Open a file with Windows' "Open as" dialog:
    RUNDLL32 SHELL32.DLL,OpenAs_RunDLL filename
    
  11. Swap your mouse to left handed use (tip from "Speedy Gonzales"): I know of no command yet to undo this, but the following will get you close:
    CONTROL MAIN.CPL
    
    or:
    RUNDLL32 SHELL32.DLL,Control_RunDLL MAIN.CPL,@0,1
    
  12. Start DialUp Network:
    (Credits for these commands: Michael J. Gregg and Tom Lavedas)
    START RUNDLL32 RNAUI.DLL,RnaDial exact name of dialer entry
    TRACERT -h 1 -w 1
    
    The RUNDLL command starts DUN, the TRACERT command is supposed to actually start the dialing process. Since I do not have access to any PC with DUN installed, I could not test the TRACERT command's effect.
     
  13. Open "Connect to Printer" dialog:
    RUNDLL32 WINSPOOL.DRV,ConnectToPrinterDlg
    
    This commands opens the "Connect to Printer" dialog, as you might have guessed. I don't see any useful application yet, but maybe you do.
     

 

Notes:   1   See my Shutdown page for more information and examples on reboot and shutdown command lines.
  2   By associating *.CPL files with the command
RUNDLL32 SHELL32.DLL,Control_RunDLL %1,@0
and *.SCR files with
RUNDLL32 DESK.CPL,InstallScreenSaver %1
you can open and/or install them by doubleclicking on their icons.

 

The following batch file installs a screensaver if one is specified, and opens the Control Panel applet at the right tab to enable adjustment of its settings (tested in NT only):

@ECHO OFF
IF "%1"=="" GOTO Interact
IF NOT EXIST %SystemRoot%.\System32\%~nx1 GOTO Interactive

RUNDLL32 DESK.CPL,InstallScreenSaver %~f1
GOTO End

:Interactive
RUNDLL32 SHELL32.DLL,Control_RunDLL DESK.CPL,@0,1

:End

 


 

I am interested to hear about other possible uses for RUNDLL.
Please send me your tips or comments by e-mail: info@robvanderwoude.com .

 

For programmers, there is more information on Microsoft's INFO: The Windows 95 Rundll and Rundll32 Interface page and on Robert Vivrette's The Unofficial Newsletter of Delphi Users you can find an article about RUNDLL by Wendell Jones (brought to my attention by William Brooks in response to this request for tips; thanks).

At The Visual Basic Developers Resource Centre a list of Control Panel Functions for Windows 9x/NT through RUNDLL can be found (a tip from my collegue Adriaan Westra; thanks).