Click here to Skip to main content
15,883,623 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to keep the explorer.exe KILLED till an event.

I mean i have an xml file which i read from my windows service background worker. It waits for a value, till than the explorer.exe should not execute, its for security purpose.

I have tried till now :

VB
While (True)
                Dim doc As New XmlDocument
                doc.Load("C:\Users\Alpha-Guy\AppData\Local\Packages\new-design_sa0tb4645bqbp\LocalState\metadata.xml")
                Dim list = doc.GetElementsByTagName("authenticated")
                var_auth = list(0).InnerText

                If var_auth = "0" Then
                    Dim pro As Process
                    pro = Process.GetProcessesByName("explorer")(0)
                    If pro IsNot Nothing Then
                        pro.Kill()
                    End If
                End If

                If var_auth = "1" Then
                    Dim pro As Process
                    pro = Process.GetProcessesByName("explorer")(0)
                    If pro Is Nothing Then
                        Process.Start("c:\windows\explorer.exe")
                    End If

                    'Try
                    '    pro = Process.GetProcessesByName("explorer")(0)
                    'Catch ex As Exception
                    '    Process.Start("c:\windows\explorer.exe")
                    'End Try

                End If

            End While


this code is written in backgroundWorker's doWork() event.

my windows service will check for a value in xml database, if its 0 then it will check if explorer.exe is started or not, if yes than kill it.

if the value in xml file i found 1 than it will check if explorer.exe is started or not, if not than start it.

Problem : when i start the service, it kills the explorer.exe once, but explorer.exe open automatically and the service fails to kill it again.

Error : Accecss is denied.

if its some permission problem than how would it killed first time ??

Is there any problem with the code ???
Posted

I don't think you can permanently kill explorer.exe. It is a key part of the Windows operating system. If you want some security over data that you must right to the hard drive, please consider using the classes available in the.NET Framework Namespace System.IO.IsolatedStorage namespace or encrypting the data as you write it to disk.
 
Share this answer
 
You can't reliably kill Explorer.exe. It's what Windows considers a "critical process". You can kill it, but it'll repeatedly be relaunched. Constantly killing the process can lead to system instability.

The better solution is to not have someone logged in at the console.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900