BobNoobGuy
BobNoobGuy

Reputation: 1645

CMD prompt using existing file explorer?

I just learned a simple command in cmd prompt to open a specific folder using file explorer. http://www.vb-helper.com/howto_open_windows_explorer.html

 explorer.exe /e, C:\users

Is it possible, to check if I already have a file explorer open, I just change the path?

I will be coding in VB6.

Thank you

I tried.

Set sh= CreteObject("Shell.Application")
sh.navigate("c:\users",,"Explorer") 

The error I get is "Compile error: Expected: ="

same error when I try this way

Set sh = CreateObject("shell.application")
For Each w In sh
    w.navigate("C:\Users",,Explorer)
Next

random try. but still no luck:

Shell.navigate("C:\Users", , "explorer")

Upvotes: 0

Views: 163

Answers (1)

woxxom
woxxom

Reputation: 73846

In Visual Basic use Shell.Application COM Object, enumerate its Windows property, find the window you want and then use its Navigate method to change the address.

Dim sh As Shell
Set sh = New Shell
If sh.Application.Windows.Count > 0 Then
   sh.Application.Windows.Item(0).Navigate "r:\"
End If

P.S. In the Project menu, go to References, enable Microsoft Shell Controls And Automation.

Upvotes: 1

Related Questions