OLE Shell functions
Keywords: shell helper object application wscript
Starting Internet Explorer 4, there has been a desktop shell helper object called Shell.Application.This object lets you manipulate the desktop and access other system operations.
Things you can do:
- Create explorer windows
- Tile, minimise and restore the desktop
- Copy/Move files displaying the standard progress animation
- Execute commands associated with applications.
ShellApplication = ObjectOpen("Shell.Application")Windows 98, ME, 2000 and XP users should have no trouble with this object. If you have Windows 95 or NT 4 and installed IE 5 without upgrading from IE 4 then you may get an error when trying to use this object. If you have already installed IE 5 then try this command:For NT
IE5Setup.exe /C:"ie5wzd /e:IE4Shell_NTx86 /I:Y"For 95IE5Setup.exe /C:"ie5wzd /e:IE4Shell_WIN /I:Y"
Examples:Copy file
oSHApp = ObjectOpen("Shell.Application") source = "C:\temp\test.txt" target = "C:\temp2\" oNameSpace = oSHApp.Namespace(target) oNameSpace.CopyHere(source) ObjectClose(oNameSpace) ObjectClose(oSHApp)This script minimizes all open windows then opens a number of folders.winddir = DirWindows(0) oWSHShell = ObjectOpen("WScript.Shell") oSHApp = ObjectOpen("Shell.Application") oSHApp.MinimizeAll oSHApp.Open("C:\") oSHApp.Open(winddir) ;oSHApp.Open("\\PDC\netlogon") oSHApp.TileVertically oWSHShell.popup("Restore Desktop") oSHApp.UndoMinimizeAll ObjectClose(oWSHShell) ObjectClose(oSHApp) ExitFor a list of shell objects and methods see:
http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/reference/objects/objects.asp?frame=true
Some shell commands from msdn to perform different actions:oShell = ObjectOpen("Shell.Application") ;Minimizes all windows on the desktop ;oShell.MinimizeAll ;Displays the Run dialog box ;oShell.FileRun ;Displays the Shut Down Windows dialog box ;oShell.ShutdownWindows ;Displays the Find dialog box ;oShell.FindFiles ;Displays the Date/Time dialog box ;oShell.SetTime ;Runs a Control Panel application ;(Internet Properties dialog box) ;oShell.ControlPanelItem("INETCPL.cpl") ;Explores a folder ;oShell.Explore ("C:\YourFolder") ;Enables user to select folder ;returns a handle to wich you can apply methods ;handle=oShell.BrowseForFolder (0, "Text", 0, "C:\YourFolder") ;Opens a folder ;oShell.Open ("C:\YourFolder") ;Displays the Taskbar Properties dialog box ;oShell.TrayProperties ObjectClose(oShell)
Article ID: W15232