Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET .NET4 Services
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 :
 
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 24-Mar-13 11:58am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  

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

  Print Answers RSS
0 Kornfeld Eliyahu Peter 275
1 Maciej Los 214
2 Sergey Alexandrovich Kryukov 200
3 King Fisher 185
4 OriginalGriff 163
0 OriginalGriff 6,223
1 DamithSL 4,724
2 Maciej Los 4,196
3 Kornfeld Eliyahu Peter 3,894
4 Sergey Alexandrovich Kryukov 3,496


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 24 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100