问题描述
我试图让explorer.exe杀死直到活动。
我的意思是我有一个xml文件,我从我的Windows服务后台工作者那里读取。为了安全起见,它等待一个值,直到explorer.exe不应该执行为止。
我到现在为止尝试过:
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
这段代码是用backgroundWorker的doWork()事件编写的。
我的windows服务会在xml数据库中检查一个值,如果是0,那么它会检查是否explorer.exe启动与否,如果是,则杀死它。
如果xml文件中的值找到1,则检查explorer.exe是否已启动或不,如果不是启动它。
问题:当我启动服务时,它会杀死explorer.exe一次,但是要探索r.exe自动打开,服务无法再次杀死它。
错误:Accecss被拒绝。
如果它的一些权限问题比第一次杀死它怎么样?
代码是否有任何问题???
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 ???
推荐答案
这篇关于从Windows服务中删除进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!