Using Rundll32 For Administrative Functions
Windows Only (Windows NT/2000/XP Only)

The tip below is from the July 2002 issue of Windows & .NET Magazine, modified for use with MetaCard/Revolution. - Ed.

Many common administrative functions in WIndows are encapsulated in DLLs. Fortunately, Windows provides rundll32.exe, a command-line utility that lets you execute some DLL functions.

Administrative Function DLL Code
Launch Internet Explorer to a specific web site url.dll set the hideConsoleWindows to true
get shell("rundll32.exe url.dll,FileProtocolHandler http://www.sonsothunder.com/")
Add a printer to a local computer by starting the Add Printer Wizard printui.dll set the hideConsoleWindows to true
get shell("rundll32.exe printui.dll,PrintUIEntry /il")
Add a printer to a remote computer by starting the Add Printer Wizard

Note: The example is for a printer called "LJ4100DTNPS" on the server volume "MyServer"). Note that it is the "real" name of the printer that is used, not the "friendly name" (like "HP LaserJet 4100 PS").

printui.dll set the hideConsoleWindows to true
get shell("rundll32.exe printui.dll,PrintUIEntry /il /c\\MyServer\LJ4100DTNPS")
Add printer port for attached TCP/IP printers by starting the Add TCP/IP Printer Port Wizard tcpmonui.dll set the hideConsoleWindows to true
get shell("rundll32.exe tcpmonui.dll,LocalAddPortUI")
Start the Network Identification Wizard netplwiz.dll set the hideConsoleWindows to true
get shell("rundll32.exe netplwiz.dll,NetAccWizRunDll")
Start the Network Place Wizard netplwiz.dll set the hideConsoleWindows to true
get shell("rundll32.exe netplwiz.dll,AddNetPlaceRunDll")
Create a new shared folder by launching the New Share dialog box ntlanui.dll set the hideConsoleWindows to true
get shell("rundll32.exe ntlanui.dll,ShareCreate")
Manage network shares by launching the Shared Directories dialog box ntlanui.dll set the hideConsoleWindows to true
get shell("rundll32.exe ntlanui.dll,ShareManage")
Launch Device Manager devmgr.dll set the hideConsoleWindows to true
get shell("rundll32.exe devmgr.dll,DeviceManager_Execute")
Lock your workstation user32.dll set the hideConsoleWindows to true
get shell("rundll32.exe user32.dll,LockWorkStation")
Automatically log off a user or shut down your machine shell32.dll set the hideConsoleWindows to true
get shell("rundll32.exe shell32.dll,SHExitWindowsEx 0")

Posted 7/16/2002 by Ken Ray