Launching Windows Explorer for Specified Drive, Folder or File
MSDN links: Windows Explorer Command-Line Options Run Method (Windows Script Host) ShellExecute Function
$SAMPLECODE$
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 * 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)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 * SHELLEXECUTE() Windows API. DECLARE Long ShellExecute IN "Shell32.dll" ; Long 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)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 * 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
Comments