Kill explorer process and disable it restart automatically

Y

yxq

Hello,
I want to kill the Explorer process, after Explorer process has been killed,
it will restart automatically immediately. How to disable it restart
automatically? for example, in Windows Task Manager, you can kill explorer
process, but it will not restart automatically.

My code:

/////////////////////////////////////////////
For Each ObjPro As Process In Process.GetProcessesByName("EXPLORER")
ObjPro.Kill()
Do Until ObjPro.HasExited = True
Application.DoEvents()
Loop
Next
////////////////////////////////////////////
 
C

coolCoder

Hello,
I want to kill the Explorer process, after Explorer process has been killed,
it will restart automatically immediately. How to disable it restart
automatically? for example, in Windows Task Manager, you can kill explorer
process, but it will not restart automatically.

My code:

/////////////////////////////////////////////
For Each ObjPro As Process In Process.GetProcessesByName("EXPLORER")
ObjPro.Kill()
Do Until ObjPro.HasExited = True
Application.DoEvents()
Loop
Next
////////////////////////////////////////////

Hi,
May I know why you want to kill Explorer process from your code,
since this is a System process ? May be there is workaround for your
problem.
Also please specify more details about your actual problem.


Thanks,
coolCoder
 
J

Joel Merk

I have found that using a loop (possibly within a separate thread, or perhaps
a timer, depending on how you want to do it) to constantly check if Explorer
has restarted, and then kill it again works well. After a while, it stops
automatically restarting. Not that I recommend doing it, but if you feel that
you need to, then that's how I suggest doing it.
 
Y

yxq

I have done successfully.
///////////////////////////////////////////////////////////////
Public Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As
IntPtr, ByVal uExitCode As UInteger) As Integer

For Each ObjPro As Process In Process.GetProcessesByName("EXPLORER")
TerminateProcess(ObjPro.Handle, 1)
Do Until ObjPro.HasExited = True
Application.DoEvents()
Loop
Next
///////////////////////////////////////////////
 
Y

yxq

Public Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As
IntPtr, ByVal uExitCode As UInteger) As Integer

For Each ObjPro As Process In Process.GetProcessesByName("EXPLORER")
Do Until TerminateProcess(ObjPro.Handle, 1)
Application.DoEvents()
Loop
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top