Page 1 of 1

Opening Windows explorer and closing it after a few seconds?

Posted: Thu Apr 12, 2007 10:26 pm
by Kaiser
Hey guys, long time I don't post here, heh... anyways, I'm trying to solve an issue of a friend of mine... he has to use an OOOOOLD program that needs a network folder mapped as a drive (in this case, K:\ ). However, the program won't work until he opens windows explorer, double-click K: then close it again - it's annoying xD.

So I wanted to help him in some way... thing is, I've tried tons of stuff I've found around in the forums, I've tried the PBOSL libraries... almost everything that came to mind (even Windows API) but it never killed Explorer. All I do is run explorer like this:

explorer.exe k:\

And I want to close it after a few seconds (2-5 seconds) so it does the job automatically for him. Anybody know how to do that? I've tried with runprogram, runprogramex, createprocess.... I'm out of ideas!

Or, it could be too, that if any of you know how to solve the mapped network drive issue, it would be awesome too, without the need of making a specific program for this!

thanks in advance guys, you all rock! :D

Posted: Thu Apr 12, 2007 11:02 pm
by Edwin Knoppert
I don't get it but ok, try the subst command?

Something like:
c:\WINDOWS\system32\Subst P: c:\PDrive

Posted: Fri Apr 13, 2007 7:09 am
by Kaiser
Edwin Knoppert wrote:I don't get it but ok, try the subst command?

Something like:
c:\WINDOWS\system32\Subst P: c:\PDrive
Nice idea, I'll try it tomorrow, thanks :)

Just wondering, does it work with network paths such as \\ComputerName\Folder or another mapped network drive made with the Explorer menu -> Tools -> Connect to network drive ?

Posted: Fri Apr 13, 2007 4:11 pm
by Edwin Knoppert
sorry, but i really did not understand e the explorer idea at all, so i can't judge your situation.

I don't think you can subst on a nw drive.

Posted: Fri Apr 13, 2007 6:41 pm
by Kaiser
Eh, the idea is basic: Just open an explorer window (or any app) and close it after a few seconds.

I've tried this (From the codearchive)

Code: Select all

Debug "Start program..."
ProcessId.l = RunProgram("c:\windows\explorer.exe","z:\","",#PB_Program_Open) 
Debug "ProcessID = " + Str(ProcessId)

Debug "We will wait 3 seconds now..."
Delay(1000)
Debug "We will wait 2 seconds now..."
Delay(1000)
Debug "We will wait 1 seconds now..."
Delay(1000)

KillProgram(ProcessId)
CloseProgram(ProcessId)

Debug "Program terminated..."
I've also tried other stuff found in the forum... nothing has worked - something seems an alternative... in explorer options, I can select to run the folders process in a separate process (8Mb+ more in RAM, but then I have the folders in a separate EXPLORER.EXE) so I can kill it... but it hasn't worked either >.<!! :mad:

Posted: Fri Apr 13, 2007 7:22 pm
by Clutch
Will 'NET USE' work better than opening/closing explorer.exe?

Code: Select all

Procedure netUse(dvc$, unc$)
  RunProgram("cmd.exe", "/c net use " + dvc$ + " /delete", "")
  Delay(250)
  RunProgram("cmd.exe", "/c net use " + dvc$ + " " + unc$ + " /persistent:yes", "")
  Delay(250)
EndProcedure

netUse("K:", "\\computerName\shareName")

If FileSize("K:\") = -2
  Debug "K:\ is a directory"
EndIf

Posted: Wed Apr 18, 2007 3:25 pm
by milan1612
Hi,
@Kaiser's last code:
You try to "KillProgram" the explorer.exe!
I don't think that's a good idea :D
Have you tried to close just the explorer window by CloseWindow_(hwnd)?
Of course you would need the windows handle, but that shouldn't
be to hard (e.g. FindWindow_())

Regards, milan1612

Opening Windows explorer and closing it after a few seconds?

Posted: Sun Jul 29, 2007 3:35 am
by don.seglio
If the drive is already mapped you do not need to open explorer, and you need it to do some activity that reconnects the drive. A batch file with something like;

dir k:\ > c:\windows\temp\x.x

will do the trick the redirection is only needed if you don't want to see it, if you set the properties of the batch file to have it's window minimized, and place a shortcut in the startup folder it will be invisible to the user but after every boot the K: drive will re-connect.

Don.Seglio

Posted: Sun Jul 29, 2007 2:34 pm
by Pantcho!!
use send keys and send it a ALT+F4