Sign in to follow this  
Followers 0
Achilles

ProcessClose('explorer.exe") not working as expected

5 posts in this topic

It's fairly straight forward, I'm not sure why it's doing it. I want explorer.exe to be closed for a second or two so I can change a few settings, but with this automatically restarting itself it's not working.

I tried closing it from the Task Manages and it worked absolutely fine.

This is what I'm running, the msgbox displays 1:

Msgbox(0, '', ProcessClose('explorer.exe'))

AutoIt 3.3.6.1, Windows 7 32bit


My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

#2 ·  Posted (edited)

Strange behavior... I get the same.

For now I guess just use something like taskkill

Run('TASKKILL /F /PID ' & ProcessExists('explorer.exe'))

EDIT: Tried a few more things... interesting results:

This one will restart explorer when closed. This calls TerminateProcess in Kernel32.dll without a forceful close.

$Kernel32 = DllOpen("kernel32.dll")
$hproc = DllCall($Kernel32, 'int', 'OpenProcess', 'int', 0x1F0FFF, 'int', True, 'int', ProcessExists('explorer.exe'))
DllCall($Kernel32, "int", "TerminateProcess", "int", $hproc[0], "dword", 0)
DllClose($Kernel32)

This one will close explorer with an exit code of 1 and explorer does not restart.

$Kernel32 = DllOpen("kernel32.dll")
$hproc = DllCall($Kernel32, 'int', 'OpenProcess', 'int', 0x1F0FFF, 'int', True, 'int', ProcessExists('explorer.exe'))
DllCall($Kernel32, "int", "TerminateProcess", "int", $hproc[0], "dword", 1)
DllClose($Kernel32)
Edited by danwilli

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Well, it's a built in system executable. Without sending wm_close to the explorer.exe window, without using start/close method, I'd imagine the only other way would be to inject code into explorer.exe and fire off the exit method.

The above is without any research, so take it as you wish.

Edit:

I'd like to say this though, keep in mind that a lot of objects are tied to that explorer.exe. Doing it program-magically could cause a lot of issues for someone down the road. Maybe not you specifically at the moment, but someone I'm sure.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

@danwilli: thanks for those examples.. I'll probably use the last one provided I don't find a better method of doing what this entire program is meant for..

@smoke_n: In regards to your added edit, I had given that some thought but it seemed like Windows 7 had done a good job of letting explorer be shut down without problems.. however, this is closely related to this topic where I'm trying to set a different directory as what the user sees on their desktop.. the one idea I was given was to restart explorer and that seemed to work... if you have any other ideas I would be very happy to hear them as restarting explorer seems a bit ghetto and unprofessional..

Edit: reworded a bit

Edited by Achilles

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

Hi to all,

I'm sorry if I am opening an old post (not so old).

Anyway that's what I would to do:

Close the actual-user explorer and open an administrative explorer.

What I did in the beginning was:

ProcessClose("explorer.exe")
Sleep(100)
For $i=0 to 6

        if RunAs($sUsername, @ComputerName, $sPassword[$i], "explorer", "0") Then  ;START IF <<<<<<<<< Lancio runas /user:NOMEMACCHINA\nomeutenteamministrativo cmd, specificando anche la password amministrativa
            Sleep(100)
            $i=6 ; Forzo l'uscita dal ciclo.
        EndIf ;end if
Next

Pratically first I close the user explorer, after I open a new explorer with the RunAs command.

Well, this doesn't work.

So far I can only close explorer with danwilli's support:

Run('TASKKILL /F /PID ' & ProcessExists('explorer.exe'))

I really don't know how to open the new process. The syntax is right, I mean the RunAs.

The only way I found is open a cmd.exe with RunAs function then use the Send function to write what i need.

The only big problem is: I cannot touch the keyboard or I need to pay attention to the mouse click.

Can someone help me?

Thanks

Share this post


Link to post
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
Sign in to follow this  
Followers 0