CrimsonRiot Posted October 24, 2007 Share Posted October 24, 2007 How would I create a new explorer window to open a specific location, such as "c:\WINDOWS\system32\"? Link to comment Share on other sites More sharing options...
NELyon Posted October 24, 2007 Share Posted October 24, 2007 $dirPath = "c:\WINDOWS\system32" If FileExists($dirPath) Then run("explorer.exe "& $dirPath) Else MsgBox(0, "error", "Directory does not exist") EndIf Link to comment Share on other sites More sharing options...
weaponx Posted October 24, 2007 Share Posted October 24, 2007 Make sure you put the path in quotes if it has spaces in it. $dirPath = "c:\WINDOWS\system32" If FileExists($dirPath) Then run('explorer.exe "'& $dirPath & '"') Else MsgBox(0, "error", "Directory does not exist") EndIf Link to comment Share on other sites More sharing options...
CrimsonRiot Posted October 24, 2007 Author Share Posted October 24, 2007 excellent! ty very much. I was on the right track, just needed a little push. Link to comment Share on other sites More sharing options...
NELyon Posted October 24, 2007 Share Posted October 24, 2007 Make sure you put the path in quotes if it has spaces in it. $dirPath = "c:\WINDOWS\system32" If FileExists($dirPath) Then run('explorer.exe "'& $dirPath & '"') Else MsgBox(0, "error", "Directory does not exist") EndIf I didn't really bother as c:\WINDOWS\system32\ doesn't have any spaces in it Link to comment Share on other sites More sharing options...
JohnBailey Posted October 24, 2007 Share Posted October 24, 2007 Another Method: Local $dirPath = "c:\WINDOWS\system32" If Not FileExists($dirPath) Then MsgBox(0, "Explorer Open - Error", "Directory does not exist: "&$dirPath) Exit EndIf $oShell = ObjCreate("shell.application") $oShell.open($dirPath) ;OR $oShell.explore($dirPath); this will get the explorerbar to open with the Folders toolbar If you're interested in control it once it's opened Local $dirPath = "c:\WINDOWS\system32" If Not FileExists($dirPath) Then MsgBox(0, "Explorer Open - Error", "Directory does not exist: "&$dirPath) Exit EndIf $oShell = ObjCreate("shell.application") Local $oShellWindows = $oShell.windows Local $currentTotal = $oShell.windows.count;First get the current explorer window count Local $PreviousBound = $currentTotal-1;Used later $oShell.open($dirPath);Open new $PreviousBound +=1 While 1;This will give it time to open (if you don't do this it will error out) Local $currentTotal = $oShell.windows.count ConsoleWrite('$currentTotal: '&$currentTotal & ' vs '&($PreviousBound+1)&@LF) If $currentTotal = ($PreviousBound+1) Then ExitLoop EndIf Sleep(100) WEnd Local $Window = $oShell.windows.item($PreviousBound) Local $WindowHwnd = HWnd($window.HWnd());NOW you have the Handler for the new Explorer Window ; Examples for manipulation to the new Explorer Window WinSetTitle($WindowHwnd,'','New Window') MsgBox(0,'Explorer Command','Navigation to C:\ will take place in five seconds or on ok.',5) $window.Navigate('C:\'); Notice how with the COM commands you don't use the HWnd A decision is a powerful thing Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now