Opening Windows explorer and closing it after a few seconds?

Windows specific forum
Kaiser
Enthusiast
Enthusiast
Posts: 118
Joined: Tue Jan 11, 2005 8:36 am

Opening Windows explorer and closing it after a few seconds?

Post 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
Image
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Post by Edwin Knoppert »

I don't get it but ok, try the subst command?

Something like:
c:\WINDOWS\system32\Subst P: c:\PDrive
Kaiser
Enthusiast
Enthusiast
Posts: 118
Joined: Tue Jan 11, 2005 8:36 am

Post 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 ?
Image
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Post 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.
Kaiser
Enthusiast
Enthusiast
Posts: 118
Joined: Tue Jan 11, 2005 8:36 am

Post 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:
Last edited by Kaiser on Fri Apr 13, 2007 8:42 pm, edited 1 time in total.
Image
Clutch
User
User
Posts: 52
Joined: Sun Nov 26, 2006 6:11 am
Location: South Florida

Post 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
"Ahead one third... ahead two thirds... Full ahead flank
And out from the belly of the whale came a prophet, Amen"
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

Post 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
don.seglio
New User
New User
Posts: 3
Joined: Fri Oct 27, 2006 6:15 pm
Location: NW Arkansas, USA

Opening Windows explorer and closing it after a few seconds?

Post 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
Pantcho!!
Enthusiast
Enthusiast
Posts: 538
Joined: Tue Feb 24, 2004 3:43 am
Location: Israel
Contact:

Post by Pantcho!! »

use send keys and send it a ALT+F4
Post Reply