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:
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 |
RUNDLL32 modemui.dll,InvokeControlPanel
Credits: Jeffrey W. Horning (posted on JSI FAQ)
(Windows 95)
RUNDLL SYSDM.CPL,InstallDevice_Rundll
Credits: Faris Mlaeb
(Windows 2000 or later, or Windows 98 SE with hotplug.dll installed):
RUNDLL32 SHELL32.DLL,Control_RunDLL hotplug.dll
Credits: Chris S./Dx21.com
RUNDLL32 devmgr.dll DeviceManager_Execute
Credits: Jeffrey W. Horning (posted on JSI FAQ)
(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
(Windows 2000)
RUNDLL32 USER32.DLL,LockWorkStation
Credits: Steven Clements (posted on alt.msdos.batch.nt)
(Windows 95)
RUNDLL USER,repaintscreen
Credits: Faris Mlaeb
(Windows 95)
Credits: Faris Mlaeb
(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)
(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
RUNDLL MOUSE,ENABLE
Credits: Faris Mlaeb
RUNDLL32 SHELL32.DLL,SHHelpShortcuts_RunDLL AddPrinter
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.
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 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
(Windows 2000)
RUNDLL32 PRINTUI.DLL,PrintUIEntry /?
This will display an extensive list of available functions
and many examples.
View this same list in HTML.
RUNDLL32 tcpmonui.dll,LocalAddPortUI
Credits: Jeffrey W. Horning (posted on JSI FAQ)
RUNDLL32.EXE iedkcs32.dll,Clear
Credits: "pradeep" (posted on Go4Expert Forum)
RUNDLL32.EXE shdocvw.dll,DoOrganizeFavDlg
Credits: "pradeep" (posted on Go4Expert Forum)
RUNDLL32.EXE 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.
Credits: Herby on neowin.net
RUNDLL32 SHELL32.DLL,SHFormatDrive
RUNDLL32 DISKCOPY.DLL,DiskCopyRunDll
Credits: Media Chance
(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)
RUNDLL32 netplwiz.dll,NetAccWizRunDll
Credits: Jeffrey W. Horning (posted on JSI FAQ)
RUNDLL32 netplwiz.dll,AddNetPlaceRunDll
Credits: Jeffrey W. Horning (posted on JSI FAQ)
(Windows 2000/XP)
RUNDLL32 PowrProf.dll, SetSuspendState
Credits: TechRepublic's Windows XP Newsletter & Graham Smith.
(Windows 9*)
RUNDLL SHELL.DLL,RestartDialog
Showing version, servicepack, registered owner and amount of physical memory:
RUNDLL32 SHELL32.DLL,ShellAboutW
RUNDLL32 SHELL32.DLL,OpenAs_RunDLL filename
(Windows XP)
RUNDLL32.EXE ZIPFLDR.DLL,RouteTheCall zipfile.ZIP
Unfortunately, there seems to be no (native) command to copy files into the .ZIP file
(tip from "Speedy Gonzales")
RUNDLL USER.EXE,SwapMouseButtonRUNDLL32 USER32.DLL,SwapMouseButtonI 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
(Windows 95)
RUNDLL RNAUI.DLL,RnaWizard
Credits: Faris Mlaeb
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.
RUNDLL32 SHELL32.DLL,SHHelpShortcuts_RunDLL FontsFolder
Credits: Media Chance
RUNDLL32 dsquery,OpenQueryWindow
This allows you to search Active Directory for users or computers, though only a limited part of the properties is accessible.
Credits: TechRepublic's Windows XP e-Newsletter for August 5, 2004
in HKEY_CURRENT_USER without logging off (Windows 2000 and later):
RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters ,1 ,True
Credits: Pete Smith.
(Windows XP)
RUNDLL32 advpack.dll,LaunchINFSection %windir%\INF\msmsgs.inf,BLC.Remove
Credits: Pascal Rebsamen (posted on WinBoard)
(Windows XP)
RUNDLL32 setupapi,InstallHinfSection DefaultInstall 132 inf_file.INF
or (IE 4+):
RUNDLL32 advpack.dll,LaunchINFSection inf_file.INF,DefaultInstall
Command for Vista and Windows 7:
InfDefaultInstall.exe inf_file.INF
(Windows XP)
RUNDLL32 setupapi,InstallHinfSection DefaultInstall 132 %windir%infie.inf
Credits: Pascal Rebsamen (posted on WinBoard)

(Windows 7)
RUNDLL32 DwmApi #105
Credits: Scott Dunn, WindowsSecrets
(Windows 7)
Turn ON Aero:
RUNDLL32 DwmApi #102
Turn OFF Aero:
RUNDLL32 DwmApi #104
Credits: Vishal Gupta
| Notes: | (1) | See my Shutdown page for more information and examples on reboot and shutdown command lines. |
| (2) | By associating *.CPL files with the commandRUNDLL32 SHELL32.DLL,Control_RunDLL %1,@0and *.SCR files with RUNDLL32 DESK.CPL,InstallScreenSaver %1you can open and/or install them by doubleclicking on their icons. |
Back to the top of this page . . .
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
| I am interested to hear about other possible uses for RUNDLL32. Please send your tips or comments to my e-mail address. |
Back to the top of this page . . .
An extensive list of RUNDLL commands with good search capabilities can be found at Dx21's RunDLL32 section.
Another good source is Using Rundll32.exe in Windows Vista and Windows 7 by Victor Laurie.
For programmers, there is more information on Microsoft's Windows 95 Rundll and Rundll32 Interface page.
Peter A. Bromberg's Short RunDll32 Primer for Developers.
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).
Search Microsoft.com for more info on INF files.
Back to the top of this page . . .
| page last uploaded: 13 February 2012, 21:59 |