Jump to content

Runwait problem with explore.exe


Recommended Posts

I'm trying to open an explorer window and pause the script until it closes, but failing on this apparently simple task!

MsgBox(0, "File transfer", "This will open Windows Explorer")
 RunWait ("explorer.exe"); c:\ToBeEncrypted") 
 MsgBox(0,"waited?", "waited?")
    exit

The above runs explorer, but doesn't wait - heads on to the message box immediately.

I've tried ShellExecuteWait and the processWaitClose as per the helpfile example:

$PID = Run("explorer.exe")
ProcessWaitClose($PID)
MsgBox(0,"waited?", "waited?")
    exit

but this does the same.

Can anyone suggest a way to open an explorer window and pause the script until it has been closed? I presume explorer.exe is somehow 'special'.

Regards,

William

Link to comment
Share on other sites

If explorer.exe already exists, then it will return straight away. I imagine this is something to do with the way explorer handles new instances. If explorer.exe is not already running, then it functions as expected.

Remember Run () returns the PID, so just do a while loop until the process no longer exists. But I feel this will fail too since you already tried a similar thing... Does anyone here know about how explorer works when creating a new explorer instance?

Cheers,

Brett

Link to comment
Share on other sites

If you see your desktop explorer.exe is running, explorer.exe is the whole look of windows, not just the window of My Documents or My Computer.

You can't use RunWait.

Bye

Thanks, both.

Paulo, I kinda figured I can't use runwait - hence this query!

Is there any other way round this, or is explorer.exe so 'special' it doesn't behave like any other process?

Regards,

William

Link to comment
Share on other sites

Use WinGetTitle.

#include<Process.au3>
MsgBox(0, "File transfer", "This will open Windows Explorer")
_RunDOS ("explorer.exe C:\ToBeEncrypted");You can change ToBeEncrypted for the name of the window Ex: My Documents
While 1
    If Not WinExists("ToBeEncrypted") = 1 Then ExitLoop;The same
    Sleep (100)
WEnd
MsgBox(0,"waited?", "waited?")
Exit

Bye

Link to comment
Share on other sites

Use WinGetTitle.

#include<Process.au3>
MsgBox(0, "File transfer", "This will open Windows Explorer")
_RunDOS ("explorer.exe C:\ToBeEncrypted");You can change ToBeEncrypted for the name of the window Ex: My Documents
While 1
    If Not WinExists("ToBeEncrypted") = 1 Then ExitLoop;The same
    Sleep (100)
WEnd
MsgBox(0,"waited?", "waited?")
Exit

Bye

Thanks - that looks promising!

William

Link to comment
Share on other sites

I know that this is a few days old - but I would like to clear up some statements made in case some one stumbles upon this during a forum search. The topic has a good title for the search function.

saywell:

RunWait ("explorer.exe"); c:\ToBeEncrypted")

MsgBox(0,"waited?", "waited?")

The above runs explorer, but doesn't wait - heads on to the message box immediately.

RunWait does wait but if one instance of explorer is already running, the new instance of explorer passes the parms to it and then closes. This code shows the three PIDs, but they will not be in the list of processes:

$PID1 = Run("explorer.exe")
$PID2 = Run("explorer.exe")
$PID3 = Run("explorer.exe")
MsgBox(262144,"$PID", $PID1 & @cr & $PID2 & @cr & $PID3)

PAULOGARCIA2005:

If you see your desktop explorer.exe is running, ...

~~~

You can't use RunWait.

But you can use RunWait("explorer.exe") in a script* that runs while no one is logged on or after a system restarts. The primary instance of explorer exits when you logoff.

* Not that I can think of a reason why you would want to - but....

However, when logged on - it has been my experience that explorer windows refresh their title a few times before they are ready for the user or a script to interact with them. This makes it hard to use WinWait or to rename explorer windows.

saywell - did you get some code to work for you?

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

For XP and below, there is an option available to run each explorer in it's own process in folder options. This option is unavailable in Windows 7 (on it right now) so I assume the same about Vista.

That option is also available into Vista and Seven (RC) :)

Link to comment
Share on other sites

@saywell,

Hopefully this is helpful info for you and not a thread hijack dealing with Windows OS idiosyncrasies.

Screen shots below are from W7RC1:

[i do not think that the first/left one is applicable to creating a separate process.]

Posted ImagePosted Image

...and from XP Pro SP2 running the script that I posted above. A separate process is launched for all 3 Run lines, then the OS picks one to remain. It is not always the first one launched. Note the 1968 PID.

Posted Image

This is of course after checking/applying the folder option to "Launch folder windows in a separate process".

...and just to confuse things

Vista had to be different and truly launch a separate explorer process for each folder being explored:

Posted Image...and notice the process IDs???

However, I could only get that result once... but I never got a PID that I could use. (i,e, the PID of the "extra" explorer process was never one of the ones reported by AutoIt's Run line... presumably because yet another instance of explorer is launched to handle the parms of the ones launched by AutoIt's Run line. Even if I only request one "extra" explorer process - the PID will be different on Vista and W7.)

There are 3 old registry tweaks for this area:

Launch Browser Windows in a Separate Process

Launch Folder Windows in a Separate Process

Launch Windows Desktop in a Separate Process

Enabling all 3 did not do quite what I had expected - I never saw an explorer instance for the desktop.

I'll leave it to others to attempt to get a useful PID for Vista and W7 via $PID1 = Run("explorer.exe").

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...