RUNDLL and RUNDLL32

RUNDLL and RUNDLL32 are two utilities supplied with Windows 95 and later.
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)

    General syntax:

    RUNDLL32 SHELL32.DLL,Control_RunDLL filename.CPL,@n,t

    where:

    filename.CPL
    is the name of one of Control Panel's *.CPL files,
    n
    is the zero based number of the applet within the *.CPL file, and
    t
    is the number of the tab for multi paged applets

    Examples:

    Date/time applet, Time Zone tab:
    RUNDLL32 SHELL32.DLL,Control_RunDLL TIMEDATE.CPL,@0,1
    Desktop applet, Screensaver tab:
    RUNDLL32 SHELL32.DLL,Control_RunDLL DESK.CPL,@0,1
    Network applet, Protocols tab:
    RUNDLL32 SHELL32.DLL,Control_RunDLL NCPA.CPL,@0,2
    Network applet, Adapters tab:
    RUNDLL32 SHELL32.DLL,Control_RunDLL NCPA.CPL,@0,3
    System applet, Environment tab:
    RUNDLL32 SHELL32.DLL,Control_RunDLL SYSDM.CPL,@0,2

    An alternative approach is using CONTROL.EXE.
    However, if you want to make your batch file wait for the Control Panel applet to be closed, you'll have to use the RUNDLL32 command with START /WAIT

    General syntax:

    CONTROL.EXE filename.CPL,@n,t

    where:

    filename.CPL
    is the name of one of Control Panel's *.CPL files,
    n
    is the zero based number of the applet within the *.CPL file, and
    t
    is the number of the tab for multi paged applets

    Examples:

    Date/time applet, Time Zone tab:
    CONTROL.EXE TIMEDATE.CPL,@0,1
    Desktop applet, Screensaver tab:
    CONTROL.EXE DESK.CPL,@0,1
    or alternatively, in Windows 2000 & XP:
    CONTROL.EXE DESK.CPL ,@ScreenSaver
    Note the space between the *.CPL file name and the comma.
    This seems to work for DESK.CPL only.
    Use the description on the tab, remove any spaces.

    Credits: Neil J. Rubenking, in one of his articles in PC Magazine.
    Tip: Leslie Katz
  2. Open Install new modem wizard:

    RUNDLL32 modemui.dll,InvokeControlPanel

    Credits: Jeffrey W. Horning (posted on JSI FAQ)

  3. Start "Add New Hardware" Wizard (Windows 95):

    RUNDLL SYSDM.CPL,InstallDevice_Rundll

    Credits: Faris Mlaeb

  4. Open the "Unplug or Eject Hardware" wizard (Windows 2000 or later, or Windows 98 SE with hotplug.dll installed):

    RUNDLL32 SHELL32.DLL,Control_RunDLL hotplug.dll

    Credits: Chris S./Dx21.com

  5. Open Device manager:

    RUNDLL32 devmgr.dll DeviceManager_Execute

    Credits: Jeffrey W. Horning (posted on JSI FAQ)

  6. Install a screensaver (copy the *.SCR file to the Windows directory first) (2):

    RUNDLL32 DESK.CPL,InstallScreenSaver C:\WINNT\SYSTEM32\Default.scr

    (To invoke the screensaver use:

    C:\WINNT\SYSTEM32\Default.scr /S

    Tip by "UnhappyEggWhisk" on forums.somethingawful.com)

    The directory shown is for Windows NT 4/2000, modify for Windows 9x/XP

  7. Lock the screen (Windows 2000):

    RUNDLL32 USER32.DLL,LockWorkStation

    Credits: Steven Clements (posted on alt.msdos.batch.nt)

  8. Redraw the screen (Windows 95):

    RUNDLL USER,repaintscreen

    Credits: Faris Mlaeb

  9. Rearrange the windows on the screen (Windows 95):

    Cascade:
    RUNDLL32 USER,cascadechildwindows
    Tile:
    RUNDLL32 USER,tilechildwindows

    Credits: Faris Mlaeb

  10. Change screen resolution (Windows 9x with PowerToys' QuickRes installed):

    RUNDLL DESKCP16.DLL,QUICKRES_RUNDLLENTRY hresxvresxbpp

    Where hres is the horizontal resolution in pixels, vres is the vertical resolution in pixels, and bpp is the number of bits per pixel.
    The following example will set the screen resolution to 800 x 600 at 256 colors (28 colors = 8 bits per pixel)

    RUNDLL DESKCP16.DLL,QUICKRES_RUNDLLENTRY 800x600x8

    Credits: William Allen (posted on alt.msdos.batch)

  11. Disable mouse and/or keyboard (Windows 9*/ME):

    RUNDLL KEYBOARD,DISABLE
    RUNDLL MOUSE,DISABLE

    There is an ENABLE function too, but I haven't found the right syntax yet. Without any further parameters it only halts the system without warning (Windows 95). You will probably need the other RUNDLL commands to do a "clean" reboot.

    Credits: Koro das Master

  12. Halt system:

    RUNDLL MOUSE,ENABLE

    Credits: Faris Mlaeb

  13. Start "Add New Printer" wizard:

    RUNDLL32 SHELL32.DLL,SHHelpShortcuts_RunDLL AddPrinter

  14. 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.

  15. Open the Printers folder:

    RUNDLL32 SHELL32.DLL,Control_RunDLL MAIN.CPL @2

    or for Windows 2000:

    RUNDLL32 SHELL32.DLL,SHHelpShortcuts_RunDLL PrintersFolder

    Credits: Pascal Rebsamen

    Note: To create a shortcut in the Start Menu to open the Printers folder, create a directory using one of the following commands.

    Windows 9x (without roaming profiles):
    MD "%windir%\Start Menu\Programs\Printers.{2227A280-3AEA-1069-A2DE-08002B30309D}"
    Windows NT 4/2000:
    MD "%USERPROFILE%\Start Menu\Programs\Printers.{2227A280-3AEA-1069-A2DE-08002B30309D}"
  16. Print a test page (Windows 95 and later; unfortunately this command does not always work):

    RUNDLL32.EXE SHELL32.DLL,SHHelpShortcuts_RunDLL PrintTestPage

    Or for Windows 9x (source: Daniel U. Thibault):

    RUNDLL32.EXE MSPrint2.DLL,RUNDLL_PrintTestPage

  17. View or change printer settings (Windows 2000):

    RUNDLL32 PRINTUI.DLL,PrintUIEntry /?

    This will display an extensive list of available functions and many examples.
    View this same list in HTML.

  18. Add a TCP/IP printer port:

    RUNDLL32 tcpmonui.dll,LocalAddPortUI

    Credits: Jeffrey W. Horning (posted on JSI FAQ)

  19. Open the dialog box for editing the Favorites in Internet Explorer:

    RUNDLL32.EXE shdocvw.dll,DoOrganizeFavDlg

    Credits: "pradeep" (posted on Go4Expert Forum)

  20. Start GUI mode disk format:

    RUNDLL32 SHELL32.DLL,SHFormatDrive

  21. Start GUI mode diskcopy:

    RUNDLL32 DISKCOPY.DLL,DiskCopyRunDll

    Credits: Media Chance

  22. "Map Network Drive" dialog (Windows 95):

    RUNDLL32 USER,wnetconnectdialog

    and for Windows XP:

    RUNDLL32 SHELL32.DLL,SHHelpShortcuts_RunDLL Connect

    Credits: Faris Mlaeb (Windows 95) and Ian Freeman (Windows XP)

  23. Manage shares:

    RUNDLL32 ntlanui.dll,ShareManage - Shares

    Credits: Jeffrey W. Horning (posted on JSI FAQ)

  24. Create a new share:

    RUNDLL32 ntlanui.dll,ShareCreate

    Credits: Jeffrey W. Horning (posted on JSI FAQ)

  25. Open the Network ID wizard:

    RUNDLL32 netplwiz.dll,NetAccWizRunDll

    Credits: Jeffrey W. Horning (posted on JSI FAQ)

  26. Open the Add network place wizard:

    RUNDLL32 netplwiz.dll,AddNetPlaceRunDll

    Credits: Jeffrey W. Horning (posted on JSI FAQ)

  27. Logoff Windows (1)

    Logoff Windows 98:
    RUNDLL SHELL32.DLL,SHExitWindowsEx
    Logoff Windows 98 and run Explorer after relogon:
    RUNDLL SHELL32.DLL,SHExitWindowsEx 4
    Logoff Windows NT 4:
    RUNDLL32 USER32.DLL,ExitWindowsEx
    RUNDLL32 USER32.DLL,ExitWindowsEx
    This is not a mistake, the command usualy must be called twice before anything happens.
  28. Reboot (1)

    Windows 95 (not reliable, sometimes only shutdown):
    RUNDLL USER.EXE,ExitWindowsExec
    Windows 98:
    RUNDLL SHELL32.DLL,SHExitWindowsEx 2
    Windows NT 4:
    @ECHO OFF
    PUSHD "%temp%"
    ECHO [Version] > {out}.inf
    ECHO signature=$chicago$ >> {out}.inf
    ECHO [defaultinstall] >> {out}.inf
    RUNDLL32 SETUPAPI,InstallHinfSection DefaultInstall 1 {out}.inf
    DEL {out}.inf
    POPD
    (original batch file by Walter Zackery, adapted for readability)
  29. Shutdown (1)

    Windows 95:
    RUNDLL USER.EXE,ExitWindows
    Windows 98:
    RUNDLL SHELL32.DLL,SHExitWindowsEx 1
    or:
    RUNDLL32 KRNL386.EXE,exitkernel
    (will also power down ATX boards)
  30. Activate suspend mode (1) (Windows 2000/XP):

    RUNDLL32 PowrProf.dll, SetSuspendState

    Credits: TechRepublic's Windows XP Newsletter & Graham Smith.

  31. Show Windows 9*'s "System setting changed, do you want to reboot now?" dialog (1):

    RUNDLL SHELL.DLL,RestartDialog

  32. Display NT's "About" dialog, showing version, servicepack, registered owner and amount of physical memory:

    RUNDLL32 SHELL32.DLL,ShellAboutW

  33. Open a file with Windows' "Open as" dialog:

    RUNDLL32 SHELL32.DLL,OpenAs_RunDLL filename

  34. Open a .ZIP file in Explorer (XP):

    RUNDLL32.EXE ZIPFLDR.DLL,RouteTheCall zipfile.ZIP

    Unfortunately, there seems to be no (native) command to copy files into the .ZIP file

  35. Swap your mouse to left handed use (tip from "Speedy Gonzales"):

    Windows 95:
    RUNDLL USER.EXE,SwapMouseButton
    Windows NT:
    RUNDLL32 USER32.DLL,SwapMouseButton

    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

  36. Start "DialUp Connection" Wizard (Windows 95):

    RUNDLL RNAUI.DLL,RnaWizard

    Credits: Faris Mlaeb

  37. Start DialUp Network:

    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, assuming automatic dialing is enabled.
    Since I do not have access to any PC with DUN installed, I could not test the TRACERT command's effect.

    Credits for these commands: Michael J. Gregg and Tom Lavedas

    Use the RASPHONE command in Windows NT, which can also hang up the connection

    Credits: Simon Sheppard.

  38. Open the Fonts folder:

    RUNDLL32 SHELL32.DLL,SHHelpShortcuts_RunDLL FontsFolder

    Credits: Media Chance

  39. TechRepublic's Windows XP e-Newsletter for August 5, 2004, showed a nice example of using RUNDLL32 to open an Active Directory Search window:

    RUNDLL32 dsquery,OpenQueryWindow

    This allows you to search Active Directory for users or computers, though only a limited part of the properties is accessible.

  40. Activate registry changes in HKEY_CURRENT_USER without logging off (Windows 2000 and later):

    RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters ,1 ,True

    Credits: Pete Smith.

  41. Remove Messenger (Windows XP):

    RUNDLL32 advpack.dll,LaunchINFSection %windir%\INF\msmsgs.inf,BLC.Remove

    Credits: Pascal Rebsamen (posted on WinBoard)

  42. Repair IE 6 (Windows XP):

    RUNDLL32 setupapi,InstallHinfSection DefaultInstall 132 %windir%infie.inf

    Credits: Pascal Rebsamen (posted on WinBoard)

 

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.

 

Install a screensaver

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 Interactive
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
Click to view source Click to download the ZIPped source

 

 

I am interested to hear about other possible uses for RUNDLL32.
Please send me your tips or comments by e-mail:                                                                                                                                                                                                                                                               
 BX                8H8                    UZPUKTM                         WT                                                   TK                                                                   8T                                                        
 EM               F5HR                 BN5WW53BUPFY                       Y3                                                   MN                                                                   85                                                        
                  UK                  5HZF      KDXB                      WT                                                   YF                                                                   DY                                                        
                  WK                 FDD          HU3                     WN                                                   58                                                                   KN                                                        
 PY  TM H35Y    XVTBVT    D33T       HY    PMV  Z5 8P  TX YW8    YYEE     PD VBUB    5P       MB   TWZF8D    VY UMDE      3WPT 3U     5D8D     RB X3Y PX     T     NV    UYDB     FT     5D    DMWX EB     WNBM            RXH3       PMDD     TU VD3X  TTUD  
 TR  EWV8PRF3   NN8PNT  WTHFDEPB    VZ   URWPRB BY 3RU HZXX83  E5E5VEUT   EWW8NPUR   W5       8Y PVTMXFPKY   KVZBDMMH    MZ8DUETX   HHB5F8ZH   ZHWFUH Y3    3XK    8M  YTHTDP3E   X5     H8   KHPBYMWZ   NHX3YWMN        EFMNY5K    XNRYREDW   MKTRRTD M3MHUX 
 RV  5NY   WHV    EV    VT    DF    VV  88H   UMM   ZU MDX     38    ZK   ZYK   BZ    XK     XU  UE     MZ   KXB   VYR   5W   XD3   X8    MR   RY5     K    FUM    5   HK    DM   W3     EF   UR   ZX5   KT    BU        BU   TRZ   VT    ZM   H8B   XPM   8H 
 3P  XY     NZ    3P   NM      B3  TU   XP     R3   3N RH     NR      D5  H8     3F   3K     F8         VK   EY     UW  8N     ZH  BR      FH  3R      XK   3 8   ET  HY      XH  DR     RV  WB     8T  W8      FU      X3     UM  YV      R5  KN    HF    TV 
 NT  V3     YR    53   F8      VZ  MF  FF      3F   EW NF     8Z      KK  FZ     D8    ZF   5V       FW8TK   YU     HN  YM     EU  NU8T5MRUR5  8D      MB  Y5 5K  UY  MK      NN  DW     FV  RU     3H  VMH5TBUF5M      XZ         VB      YE  DD    YK    FW 
 ED  RM     VB    YY   TD      PV  WP  5B      UU   HX 85     XD      3R  B3     ZT    RE   RK    EZZEETEF   UR     BB  8W     WD  RFHNTXU55D  DK       XN UN Z8 MF   FK      DK  VX     UF  5N     V5  FMEUNKUXBK      ZF         5M      NV  MZ    FE    T8 
 HX  WD     55    W3   WK      HT  H5  WY      U   H3P BT     5R      HR  X3     YE     T8 HK    BYMR   VH   8B     8X  PE     R5  NX          3N       ND YH YM 5Y   5E      RM  NP     XU  UX     NV  EB              TF         WV      HX  K5    NY    ZP 
 8P  5H     5W    ZU   PY      VX  U5  3E     EH   EV  EW     R8      UV  FE     MF     FM FH    VX     5F   FZ     VB  8Z     R5  ZN          3T        P D   E B    8V      N8  BP     UM  EN     5H  HY              RX     ZK  FY      TK  TP    ZB    UY 
 83  TU     FM    HV    WB    BD   D5  HDB   MHV  FF   ZW      8T    Y5   DYY   NV       XUY     BU    UPV   BR     FV   N3   UZD   RB    3XM  MF        YZE   VTE     8B    WK   T5V   WKF   X8   T3T   5V    XHE       B8   MED   BH    HU   UE    FW    Z8 
 WN  E3     ZY    BU    YUZZWPRZ    UV  55EPDZB8WKN    3U      Z5FMPP3Z   YBVMFRBH       KKZ     ZRKBFF8VT   RU     5X   E3BNUPVU   PYFWTPNP   ZR        UTN   3KN     ZHMW5YR5    TT5UN8XT   UENHPPDH   M8HDRHZF   MB   55VMZ8R    HXW5HU5B   Y8    8F    YM 
 F5  UW     ER    KE      VMHE      583  YVUK 8RNY  HP XV        HUKH     8K YHBW         Z       V3UXF  ZM  RV     XX    ZH3B PR     PNTFF    M5         NB   DV        TTZ5       WDV3 R5    X8Z3 WE     8XTUR    HW    MRE5K       P3RT     NT    WV    UN 
                                     UWD           XM                                                                                                                                                                                                         
                                      YT8K       PPR                                                                                                                                                                                                          
                                       ZKYPEVWRMWKF                                                                                                                                                                                                           
                                         UTYDTXZV                                                                                                                                                                                                             
                                                                                                                                                                                                                                                              

 

More to explore

 

An extensive list of RUNDLL commands with good search capabilities can be found at Dx21's RunDLL32 section.

For programmers, there is more information on Microsoft's Windows 95 Rundll and Rundll32 Interface page.
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 my request for tips; thanks).

Peter A. Bromberg's Short RunDll32 Primer for Developers.

How INF files work by Mike Williams.

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 former collegue Adriaan Westra; thanks).

An extensive list of Control Panel related and other RUNDLL commands can be found at Media Chance's RUNDLL FAQ page.

Jeffrey W. Horning provided a list of Undocuments paths to Windows 2000 tools (thanks for Viju Chellamuthu, who mailed me the link).