イベントまでexplorer.exeをKILLEDに保とうとしています。
つまり、Windows サービスのバックグラウンド ワーカーから読み取った xml ファイルがあるということです。セキュリティ上の目的で、explorer.exeが実行されないようになるまで、値を待ちます。
私は今まで試しました:
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 が一度強制終了されますが、explorer.exe が自動的に開き、サービスは再度強制終了できません。
エラー : アクセスが拒否されました。
最初にどのように殺されるかよりも、何らかの許可の問題がある場合??
コードに問題はありますか???