Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch file and NT Explorer 1

Status
Not open for further replies.

GSMike

Programmer
Feb 7, 2001
143
0
0
US
I have a batch file that says:
Code:
explorer.exe
z:

I've also tried
Code:
explorer.exe
chdir z:\


The first line works: NT Explorer launches. The second line does not. I would like to have the cursor go to a specified place in NT Explorer when it opens. Does anyone know a way to make it do this??

Thanking you in advance.
Mike K
 
launch it from a VB program (as long as your here in the VB conf)
vHandle=Shell("Explorer.Exe")
DoEvents 'let it start
The do SENDKEYS
do send keys that will place the cursor over a specific control.
 
Does this mean there is no way to do it from a batch file?
Thanks. Mike K
 
foo.bat
(contains)
explorer.exe
exit

brings up an explorer for me...is that all you are doing?
what is the chdir for?

 
why would you want to open explorer to a specific location in the first place? Also, why would you want to write a batch file to do it???
It would be much easier to just hit the windows-key + E to open explorer if easy access is all you're after!
 
good question....building on it:
if the desire is to launch Explorer with a specific
directory open, then merely make a folder
c:\shortcuts and place in it shortcuts to all such directories.
 
Thanks, dsb.
I've run

Code:
"c:\shortcuts\shortcut to cache" from the command prompt, and it opens that folder in its own window.

I was encouraged so I tried
Code:
explorer.exe
"c:\shortcuts\shortcut to cache"

in a batch file, but it didn't work.

Then I tried just
Code:
"c:\shortcuts\shortcut to cache"

in a batch file, and nothing happened.

Thanks again for your help. Mike K
 
contents of batch file:
start "C:\My Documents\My Music"

alternatively, from code:
Code:
Option Explicit

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Const SW_SHOWNORMAL = 1

Private Sub Form_Load()
    'KPD-Team 1998
    'URL: [URL unfurl="true"]http://www.allapi.net/[/URL]
    'E-Mail: KPDTeam@Allapi.net
    'Send an E-Mail to the KPD-Team
    ShellExecute Me.hwnd, vbNullString, "C:\My Documents\My Music", vbNullString, vbNullString, SW_SHOWNORMAL
End Sub
 
Thanks, Justin.
I tried your suggestion:
Code:
start "c:\shortcuts"

in a batch file, and what happens is that an command prompt window opens up, entitled "c:\shortcuts", but the cursor is at "c:\>".

What I'm looking for is to be able to position the cursor wherever I want to after launching NT Explorer, preferably with a batch file. Maybe it's not possible.

Thanks again for your help. Let me know if you have any other ideas. Mike K
 
Wow..now you're on to something.
That works great...and if I weren't such a perfectionist, I would say that is perfect.
What this does is open a window for the specified folder.
What I would really like to do, if I could, is open NT Explorer itself, and have the cursor go to a specified location.

Another question on this method: Is it possible to do this exact thing, and after the window for the specified folder has opened, modify settings for the window (view toolbar, arrange icons, etc.)? This was great. Thanks, JRodrigues!! Mike K
 
yep, that's it!! right on!!! Thanks a million! Mike K
 
for a million, you should give Justin a STAR....click right below his http:// ..createwindow line.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top