Rob van der Woude's Scripting Pages

RUNDLL and RUNDLL32

RUNDLL (16-bit) and RUNDLL32 (32-bit) are two utilities supplied with Windows 95 and later (RUNDLL became obsolete in 64-bit Windows versions).
They can call DLL functions from the command line, allowing us to create extremely powerful batch files.

Besides "unattended" commands, many RUNDLL32 commands open dialogs or wizards to change settings.
In Windows 8 and later, the latter can often be achieved even better with Microsoft's ms-settings URI scheme.
If this is the case for a RUNDLL32 command, the ms-settings "command" will be mentioned as an alternative.
Clicking an ms-settings "command" on this page will open that particular ms-setting (after confirming the default app to open the link with).
Many dialogs can also be opened in Explorer by using their CLSID. Some examples of this technique will be shown as alternatives.

On this page you'll find some examples.

Filter and highlight examples by category:
Filter:
Highlight:
  1. Start Control Panel applets (2)
  2. Open "Install new modem" wizard
  3. Start "Add New Hardware" wizard
  4. Open the "Unplug or Eject Hardware" wizard
  5. Open Device manager
  6. Install a screensaver
  7. Lock the screen
  8. Redraw the screen
  9. Rearrange the windows on the screen
  10. Change screen resolution
  11. Disable mouse and/or keyboard
  12. Halt system
  13. Start "Add New Printer" wizard
  14. Open "Connect to Printer" dialog
  15. Open the Printers folder
  16. Print a test page
  17. Manage printer settings
  18. Add a TCP/IP printer port
  19. Clear Internet Explorer branding (the annoying company name in IE's title bar)
  20. Open Internet Explorer's "Organize Favorites" dialog
  21. Delete Internet Explorer 7's browsing history, cookies and temporary files
  22. Start a Telnet session
  23. Open a URL
  24. Start GUI mode disk format
  25. Start GUI mode diskcopy
  26. "Map Network Drive" dialog
  27. Manage shares
  28. Create a new share
  29. Open the Network ID wizard
  30. Open the Add network place wizard
  31. Open the "Stored User Names and Passwords" dialog
  32. Logoff Windows (1)
  33. Reboot (1)
  34. Shutdown (1)
  35. Activate suspend mode (1)
  36. Show "You must restart your computer to apply these changes" dialog
  37. Display Windows' "About" dialog
  38. Open a file with Windows' "Open as" dialog
  39. Open a .ZIP file in Explorer
  40. Swap your mouse to left handed use
  41. Start "DialUp Connection" wizard
  42. Start DialUp Network
  43. Open the Fonts folder
  44. Open an Active Directory Search dialog
  45. Activate registry changes in HKEY_CURRENT_USER without logging off
  46. Remove Messenger
  47. Install a driver using its .INF file
  48. Repair IE6
  49. Switch between windows
  50. Turn Aero on or off
  51.  
  52. Examples
  53.  
  54. Find RUNDLL32 commands yourself
  55.  
  56. Credits
  57.  
  58. More to Explore

 

  1. Start Control Panel applets (2)

    Control Panel applets or settings windows can be opened with RUNDLL32, CONTROL or, for Windows 8..11, an ms‐settings URI.
    However, if you want to make your batch file wait for the Control Panel applet or settings window to be closed, you'll have to use the RUNDLL32 command with START /WAIT

  2. Open "Install new modem" wizard

    RUNDLL32 modemui.dll,InvokeControlPanel

    Back to the top of this page . . .

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

    RUNDLL SYSDM.CPL,InstallDevice_Rundll

    Back to the top of this page . . .

  4. Open the "Unplug or Eject Hardware" wizard

    For Windows 2000 and later versions, and Windows 98 SE with hotplug.dll installed:

    RUNDLL32 SHELL32.DLL,Control_RunDLL hotplug.dll

    Back to the top of this page . . .

  5. Open Device manager

    Back to the top of this page . . .

  6. Install a screensaver

    First copy the *.SCR file to the Windows directory (2), then run:

    RUNDLL32 DESK.CPL,InstallScreenSaver %windir%\SYSTEM32\MyNewScreensaver.scr

    To invoke the screensaver use:

    %windir%\SYSTEM32\MyNewScreensaver.scr /S

    Back to the top of this page . . .

  7. Lock the screen

    For Windows 2000 and later versions:

    RUNDLL32 USER32.DLL,LockWorkStation

    Back to the top of this page . . .

  8. Redraw the screen

    For Windows 95:

    RUNDLL USER,repaintscreen

    Back to the top of this page . . .

  9. Rearrange the windows on the screen

    For Windows 95:

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

    Back to the top of this page . . .

  10. Change screen resolution

    Back to the top of this page . . .

  11. Disable mouse and/or keyboard

    For Windows 9*/ME:

    RUNDLL KEYBOARD,DISABLE
    RUNDLL MOUSE,DISABLE

    There is an ENABLE parameter 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.

    Back to the top of this page . . .

  12. Halt system (Windos 9*/ME)

    RUNDLL MOUSE,ENABLE

    Back to the top of this page . . .

  13. Start "Add New Printer" wizard

    Back to the top of this page . . .

  14. Open "Connect to Printer" dialog

    RUNDLL32 WINSPOOL.DRV,ConnectToPrinterDlg

    Back to the top of this page . . .

  15. Open the Printers folder

    Back to the top of this page . . .

  16. Print a test page

    For Windows 2000 and later versions:

    RUNDLL32 printui.dll,PrintUIEntry /k /n"printer_name"

    For Windows 95 and later versions (unconfirmed, certainly does not work on Windows 10):

    RUNDLL32 SHELL32.DLL,SHHelpShortcuts_RunDLL PrintTestPage

    For Windows 9x:

    RUNDLL32 MSPrint2.DLL,RUNDLL_PrintTestPage

     

    Back to the top of this page . . .

  17. Manage printer settings

    For Windows 2000 and later versions:

    RUNDLL32 PRINTUI.DLL,PrintUIEntry /?

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

    Back to the top of this page . . .

  18. Add a TCP/IP printer port

    RUNDLL32 tcpmonui.dll,LocalAddPortUI

    Back to the top of this page . . .

  19. Clear Internet Explorer branding

    Remove the annoying company name in IE's title bar, that some ISPs like AOL inserted:

    RUNDLL32 iedkcs32.dll,Clear

    Back to the top of this page . . .

  20. Open Internet Explorer's "Organize Favorites" dialog

    RUNDLL32 shdocvw.dll,DoOrganizeFavDlg

    Back to the top of this page . . .

  21. Delete Internet Explorer 7's browsing history, cookies and temporary files

    RUNDLL32 inetcpl.cpl,ClearMyTracksByProcess n

    Where n can have the following values:

    1 delete browsing history (list of visited sites)
    2 delete all cookies
    8 delete temporary files (cache)
    16 delete all saved forms data
    32 delete all saved passwords
    255 delete all of the above
    4351 delete all of the above and all settings stored by add-ons

    The use of powers of 2 suggests that one can combine (add) these values, e.g. 40 to delete temporary files (8) and passwords (32) simultaneously, but I didn't test this assumption yet.

    Back to the top of this page . . .

  22. Start a Telnet session

    RUNDLL32 url.dll,TelnetProtocolHandler 10.0.0.100

    You may of course keep it simple and use:

    TELNET 10.0.0.100

    Back to the top of this page . . .

  23. Open a URL

    RUNDLL32 url.dll,FileProtocolHandler https://robvanderwoude.com/news

    Or you could simply use:

    START https://robvanderwoude.com/news

    Back to the top of this page . . .

  24. Start GUI mode disk format

    RUNDLL32 SHELL32.DLL,SHFormatDrive

    Back to the top of this page . . .

  25. Start GUI mode diskcopy

    RUNDLL32 DISKCOPY.DLL,DiskCopyRunDll

    Back to the top of this page . . .

  26. "Map Network Drive" dialog

    For Windows XP and later versions:

    RUNDLL32 SHELL32.DLL,SHHelpShortcuts_RunDLL Connect

    For Windows 95:

    RUNDLL32 USER,wnetconnectdialog

    Back to the top of this page . . .

  27. Manage shares

    Unconfirmed, does not work on Windows 10.

    RUNDLL32 ntlanui.dll,ShareManage - Shares

    Back to the top of this page . . .

  28. Create a new share

    Unconfirmed, does not work on Windows 10.

    RUNDLL32 ntlanui.dll,ShareCreate

    Back to the top of this page . . .

  29. Open the Network ID wizard

    For Windows XP only:

    RUNDLL32 netplwiz.dll,NetAccWizRunDll

    Back to the top of this page . . .

  30. Open the Add network place wizard

    For Windows XP only:

    RUNDLL32 netplwiz.dll,AddNetPlaceRunDll

    Back to the top of this page . . .

  31. "Stored User Names and Passwords" dialog

    For Windows XP and later:

    RUNDLL32 keymgr.dll,KRShowKeyMgr

    Stored User Names and Passwords dialog

    Back to the top of this page . . .

  32. Logoff Windows (1)

    For Windows 2000 and later versions we cannot, and don't need to use RUNDLL32:

    SHUTDOWN /L

    For Windows NT4:

    RUNDLL32 USER32.DLL,ExitWindowsEx
    RUNDLL32 USER32.DLL,ExitWindowsEx
    REM This is not a mistake, the command usually must be called twice before anything happens.

    For Windows 98:

    RUNDLL SHELL32.DLL,SHExitWindowsEx

    For Windows 98, run Explorer after relogon:

    RUNDLL SHELL32.DLL,SHExitWindowsEx 4

    Back to the top of this page . . .

  33. Reboot (1)

    For Windows 2000 and later versions we cannot, and don't need to use RUNDLL32:

    SHUTDOWN /R

    For Windows NT4 we need to create a helper batch file:

    @ECHO OFF
    REM Original batch file by Walter Zackery, adapted for readability
    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

    For Windows 98:

    RUNDLL SHELL32.DLL,SHExitWindowsEx 2

    For Windows 95 the RUNDLL reboot command isn't very reliable, and will sometimes only perform a shutdown:

    RUNDLL USER.EXE,ExitWindowsExec

    Back to the top of this page . . .

  34. Shutdown (1)

    For Windows 2000 and later versions we cannot, and don't need to use RUNDLL32:

    SHUTDOWN /S

    For Windows 98:

    RUNDLL SHELL32.DLL,SHExitWindowsEx 1

    or, even better,since it will also power down ATX boards:

    RUNDLL32 KRNL386.EXE,exitkernel

    For Windows 95:

    RUNDLL USER.EXE,ExitWindows

    Back to the top of this page . . .

  35. Activate suspend mode (1)

    For Windows XP and later versions:

    RUNDLL32 PowrProf.dll, SetSuspendState

    Back to the top of this page . . .

  36. Show "You must restart your computer to apply these changes" dialog (1):

    For Windows NT4 and later versions:

    RUNDLL32 SHELL32.DLL,RestartDialog

    For Windows 9*/ME:

    RUNDLL SHELL.DLL,RestartDialog

    Back to the top of this page . . .

  37. Display Windows' "About" dialog

    Back to the top of this page . . .

  38. Open a file with Windows' "Open as" dialog

    RUNDLL32 SHELL32.DLL,OpenAs_RunDLL filename

    Back to the top of this page . . .

  39. Open a .ZIP file in Explorer

    For Windows XP and later versions:

    RUNDLL32 ZIPFLDR.DLL,RouteTheCall zipfile.ZIP

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

    Back to the top of this page . . .

  40. Swap your mouse to left handed use

    For Windows NT4 and later versions:

    RUNDLL32 USER32.DLL,SwapMouseButton

    For Windows 95:

    RUNDLL USER.EXE,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

    or for Windows 8..11:

    START ms-settings:mousetouchpad

     

    Back to the top of this page . . .

  41. Start "DialUp Connection" Wizard (Windows 95)

    For Windows 95:

    RUNDLL RNAUI.DLL,RnaWizard

    Back to the top of this page . . .

  42. Start DialUp Network

    For Windows NT4 and later versions:

    START RUNDLL32 RNAUI.DLL,RnaDial exact name of dialer entry
    TRACERT -h 1 -w 1

    The RUNDLL32 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.

    As an alternative you can use the RASPHONE command, which can also hang up the connection

    Back to the top of this page . . .

  43. Open the Fonts folder

    Back to the top of this page . . .

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

    Back to the top of this page . . .

  45. Activate registry changes

    For Windows 2000 and later versions, activate registry changes in the HKEY_CURRENT_USER hive without logging off and logging in again:

    RUNDLL32 USER32.DLL,UpdatePerUserSystemParameters ,1 ,True

    Back to the top of this page . . .

  46. Remove Messenger (Windows XP only)

    For Windows XP only:

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

    Back to the top of this page . . .

  47. Install a driver using its .INF file

    For Windows Vista and later versions:

    InfDefaultInstall.exe inf_file.INF

    For Windows XP:

    RUNDLL32 setupapi,InstallHinfSection DefaultInstall 132 inf_file.INF

    For any 32-bit Windows version with Internet Explorer 4 or later:

    RUNDLL32 advpack.dll,LaunchINFSection inf_file.INF,DefaultInstall

    Back to the top of this page . . .

  48. Repair IE 6 (Windows XP only)

    For Windows XP only:

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

    Back to the top of this page . . .

  49. Switch between windows (Windows 7 only)

    For Windows 7 only:

    RUNDLL32 DwmApi #105

    Switch between windows screenshot

    Back to the top of this page . . .

  50. Turn Aero on or off (Windows 7 only)

    For Windows 7 only:

    Turn ON Aero:

    RUNDLL32 DwmApi #102

    Turn OFF Aero:

    RUNDLL32 DwmApi #104

    Back to the top of this page . . .

 

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 the *.SCR files' shortcuts.

 

Back to the top of this page . . .

 

Examples

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 NT4 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
Click to view highlighted source code Click to download the ZIPped source code

 

Back to the top of this page . . .

 

Find RUNDLL32 commands yourself

Using PowerShell you can find the commandline of a running process, which we can use to find out how RUNDLL32 opens a specific dialog.

To explain the procedure we'll use a print queue as an example.

  1. Open the "Devices and Printers" dialog
  2. Click any printer, let's assume for this explanation that its name is "MyPrinter", and click "Open print queue"
  3. Open a CMD prompt
  4. Use the command

    tasklist /fi "imagename eq rundll32.exe"

    to check if a RUNDLL32 process is running
  5. Run the following DOS command in the CMD prompt (this should be a single command line):

    powershell -Command "Get-WmiObject -Class 'Win32_Process' -Filter \""Name='rundll32.exe'\"" | ForEach-Object { $_.CommandLine }"

    or, for PowerShell 6 and later:

    pwsh -Command "Get-CimInstance -ClassName 'Win32_Process' -Filter \""Name='rundll32.exe'\"" | ForEach-Object { $_.CommandLine }"

  6. (note the escaped doublequotes)

    Alternatively, open a PowerShell prompt and issue the following PowerShell command, without the need to escape the doublequotes:

    Get-WmiObject -Class 'Win32_Process' -Filter "Name='rundll32.exe'" | ForEach-Object { $_.CommandLine }

    or, for PowerShell 6 and later:

    Get-CimInstance -ClassName 'Win32_Process' -Filter "Name='rundll32.exe'" | ForEach-Object { $_.CommandLine }
  7. If all goes according to plans, you should get a result like this:

    CommandLine
    -----------
    "C:\WINDOWS\system32\rundll32.exe" printui.dll,PrintUIEntryDPIAware /o /n "MyPrinter"

     
  8. Close the print queue dialog
  9. Now issue the command we just found, it should reopen the print queue dialog
Notes: [1] Not all dialogs are opened by RUNDLL32.
  [2] In case of static dialogs, RUNDLL32 may be terminated immediately after opening the dialog, in that case this procedure won't work.

 

Credits

Christian F. Brunner Start a Telnet session
Open a URL
"Stored User Names and Passwords" dialog
Chris S. Open the "Unplug or Eject Hardware" wizard
Daniel U. Thibault Print a test page with RUNDLL32 and MSPrint2.dll
Faris Mlaeb Start "Add New Hardware" wizard with RUNDLL
Redraw the screen with RUNDLL
Rearrange the windows on the screen with RUNDLL
Halt system with RUNDLL
"Map Network Drive" dialog with RUNDLL32 (Windows 95)
Start "DialUp Connection" Wizard with RUNDLL
Graham Smith Activate suspend mode
Herby (on neowin.net) Delete Internet Explorer 7's browsing history, cookies and temporary files
Ian Freeman "Map Network Drive" dialog (Windows XP)
Jeffrey W. Horning (on JSI FAQ) Open "Install new modem" wizard
Open Device manager
Add a TCP/IP printer port
Manage shares
Create a new share
Open the Network ID wizard
Open the Add network place wizard
Koro das Master Disable mouse and/or keyboard with RUNDLL
Leslie Katz Desktop applet, Screensaver tab with CONTROL
Media Chance Start GUI mode diskcopy
Open the Fonts folder
Michael J. Gregg Start DialUp Network with RUNDLL32 and TRACERT
Neil J. Rubenking (in PC Magazine) Desktop applet, Screensaver tab with CONTROL
Pascal Rebsamen (on WinBoard) Open the Printers folder
Remove Messenger with
Repair IE 6 with
Pete Smith Activate registry changes
"pradeep" (on Go4Expert Forum) Clear Internet Explorer branding
Open the dialog box for editing the Favorites in Internet Explorer
Scott Dunn (on WindowsSecrets) Switch between windows
Shawn Brink (on TenForums) Open Control Panel applets with Explorer by CLSID
Open Device Manager with Explorer by CLSID
Simon Sheppard Start DialUp Network with RASPHONE
"Speedy Gonzales" Swap your mouse to left handed use with RUNDLL*
Steven Clements (on alt.msdos.batch.nt) Lock the screen
TechRepublic's August 5, 2004 Windows XP e-Newsletter Open an Active Directory Search window
Tom Lavedas Start DialUp Network with RUNDLL32 and TRACERT
"UnhappyEggWhisk" (on forums.somethingawful.com) Install a screensaver
Vishal Gupta Turn Aero on or off
Walter Zackery Reboot Windows NT4 with RUNDLL32 and a helper batch file
William Allen (on alt.msdos.batch) Change screen resolution with RUNDLL
WinBatch Print a test page with RUNDLL32 and printui.dll

More to explore

 

Windows 8..11's ms-settings URI scheme for opening settings windows.

Peter A. Bromberg's Short RunDll32 Primer for Developers

Tim Fisher's list of command line commands for Control Panel applets

At The Visual Basic Developers Resource Centre a list of Control Panel Functions for Windows 9x/NT through RUNDLL can be found

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

Complete List of Windows 10 CLSID Key (GUID) Shortcuts by Shawn Brink.

 

Back to the top of this page . . .


page last modified: 2022-02-16; loaded in 0.0182 seconds