Launching Windows Explorer for Specified Drive, Folder or File
By Sergey - Posted on January 1st, 2008
MSDN links:
Windows Explorer Command-Line Options
Run Method (Windows Script Host)
ShellExecute Function
| This is sample code. Add error handling and adjust to your requirements as necessary. |
&& WSH Run Method oShell = Createobject("wscript.shell") && Open 'MyComputer' view with C: drive selected oShell.Run("%SystemRoot%\explorer.exe /n, /select, c:") && Open Windows Explorer for current folder lcCurDir = FULLPATH("") && Current folder selected oShell.Run("%SystemRoot%\explorer.exe /n, /select, " + lcCurDir) && Current folder open oShell.Run("%SystemRoot%\explorer.exe /n, /root, " + lcCurDir) && Open Windows Explorer with a file selected lcFileName = _VFP.ServerName oShell.Run("%SystemRoot%\explorer.exe /n, /select, " + lcFileName)
&& SHELLEXECUTE() Windows API. DECLARE INTEGER ShellExecute IN "Shell32.dll" ; INTEGER hwnd, STRING lpVerb, STRING lpFile, ; STRING lpParameters, STRING lpDirectory, LONG nShowCmd && Open 'MyComputer' view with C: drive selected ShellExecute (0,"", GETENV("SystemRoot") + "\explorer.exe", "/n, /select, c:", "", 1) && Open Windows Explorer for current folder lcCurDir = FULLPATH("") && Current folder selected ShellExecute (0,"", GETENV("SystemRoot") + "\explorer.exe", "/n, /select, " + lcCurDir, "", 1) && Current folder open ShellExecute (0,"", GETENV("SystemRoot") + "\explorer.exe", "/n, /root, " + lcCurDir, "", 1) && Open Windows Explorer with a file selected lcFileName = _VFP.ServerName ShellExecute (0,"", GETENV("SystemRoot") + "\explorer.exe", "/n, /select, " + lcFileName, "", 1)
&& Shell.Application #DEFINE ssfDRIVES 0x11 loShellApp = CREATEOBJECT("Shell.Application") && Open 'MyComputer' view with C: drive selected = loShellApp.NameSpace("C:") = loShellApp.Open(ssfDRIVES) && Open Windows Explorer for current folder lcCurDir = FULLPATH("") && Current folder open = loShellApp.Open(lcCurDir) &&-------------------------------------------------------------------------- && ShellSpecialFolderConstants #DEFINE ssfALTSTARTUP 0x1d #DEFINE ssfAPPDATA 0x1a #DEFINE ssfBITBUCKET 0xa #DEFINE ssfCOMMONALTSTARTUP 0x1e #DEFINE ssfCOMMONAPPDATA 0x23 #DEFINE ssfCOMMONDESKTOPDIR 0x19 #DEFINE ssfCOMMONFAVORITES 0x1f #DEFINE ssfCOMMONPROGRAMS 0x17 #DEFINE ssfCOMMONSTARTMENU 0x16 #DEFINE ssfCOMMONSTARTUP 0x18 #DEFINE ssfCONTROLS 0x3 #DEFINE ssfCOOKIES 0x21 #DEFINE ssfDESKTOP 0x0 #DEFINE ssfDESKTOPDIRECTORY 0x10 #DEFINE ssfDRIVES 0x11 #DEFINE ssfFAVORITES 0x6 #DEFINE ssfFONTS 0x14 #DEFINE ssfHISTORY 0x22 #DEFINE ssfINTERNETCACHE 0x20 #DEFINE ssfLOCALAPPDATA 0x1c #DEFINE ssfMYPICTURES 0x27 #DEFINE ssfNETHOOD 0x13 #DEFINE ssfNETWORK 0x12 #DEFINE ssfPERSONAL 0x5 #DEFINE ssfPRINTERS 0x4 #DEFINE ssfPRINTHOOD 0x1b #DEFINE ssfPROFILE 0x28 #DEFINE ssfPROGRAMFILES 0x26 #DEFINE ssfPROGRAMFILESx86 0x30 #DEFINE ssfPROGRAMS 0x2 #DEFINE ssfRECENT 0x8 #DEFINE ssfSENDTO 0x9 #DEFINE ssfSTARTMENU 0xb #DEFINE ssfSTARTUP 0x7 #DEFINE ssfSYSTEM 0x25 #DEFINE ssfSYSTEMx86 0x29 #DEFINE ssfTEMPLATES 0x15 #DEFINE ssfWINDOWS 0x24
Recent comments
1 hour 22 min ago
4 days 9 hours ago
4 days 10 hours ago
1 week 9 hours ago
1 week 10 hours ago
2 weeks 1 day ago
2 weeks 1 day ago
2 weeks 4 days ago
2 weeks 4 days ago
2 weeks 6 days ago