杀死蓝栈的过程/结束过程 [英] kill process/ end process of bluestacks
问题描述
我正在尝试制作一个程序,该程序将打开和关闭bluestacks应用程序.关闭表示完全退出应用程序.由于即使您退出bluestacks应用程序,该过程也将重新启动. 我正在尝试杀死的进程是:
I'm trying to make a program that will open and close bluestacks application. Close means totally exiting the application. Since even if you exit the bluestacks app the process will just restart. The processes I'm trying kill is:
- "HD-BlockDevice.exe"
- "HD-Agent.exe"
- "HD-LogRotatorService.exe"
- "HD-UpdaterService.exe"
当我手动终止第一个进程时,除2〜3个进程外,其他进程将关闭.每当我关闭应用程序时都要杀死四个进程,这有点痛苦,所以我要创建这个进程. 这是我的代码
When I manually kill the first process, the other process will close except for the 2~3 ones. It's kinda pain to kill four processes every time i close the application so i am creating this one. Here is my code
Public Class Form1
Dim p() As Process
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer_ProcessCheck.Start()
End Sub
Private Sub Timer_ProcessCheck_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer_ProcessCheck.Tick
p = Process.GetProcessesByName("HD-BlockDevice.exe")
If p.Count > 0 Then
' Process is running
'Button_Close.Enabled = True
Else
' Process is not running
'Button_Close.Enabled = False
End If
End Sub
Private Sub Button_Open_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Open.Click
Process.Start("C:\Program Files (x86)\BlueStacks\HD-StartLauncher.exe")
End Sub
Private Sub Button_Close_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Close.Click
'p = Process.GetProcessesByName("HD-BlockDevice.exe")
'p.kill()
'p.close()
'While p.Length > 0
'For i As Integer = p.Length - 1 To 0 Step -1
'p(i).CloseMainWindow()
'Next
'p = Process.GetProcessesByName("HD-BlockDevice.exe")
'End While
'Timer_ProcessKill.Start()
End Sub
Private Sub Timer_ProcessKill_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer_ProcessKill.Tick
For Each prog As Process In Process.GetProcesses
If prog.ProcessName = "HD-BlockDevice.exe" Then
prog.Kill()
End If
Next
End Sub
End Class
我的问题是:
- 我的进程检查器不起作用(当进程已经存在时,它不会启用关闭按钮)
- 我查过的所有进程都无法正常工作(无论如何我还是要在代码中对此进行注释)
推荐答案
在以不同角度查看它之后,我终于找到了一种通过命令提示符将其杀死的想法,并且在网上阅读了很多之后该怎么做.我终于找到了使之工作的答案...
well after looking at it on different angle i finally found an idea to kill it via command prompt... and after reading a lot on the net how to do it i finally found an answer to make it work...
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim working_area As Rectangle = SystemInformation.WorkingArea
Dim newW As Integer = working_area.Left + working_area.Width - Me.Width
Dim newH As Integer = working_area.Top + working_area.Height - Me.Height
Me.Location = New Point(newW, newH)
Timer_ProcessCheck.Start()
End Sub
Private Sub Button_Open_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Open.Click
Process.Start("C:\Program Files (x86)\BlueStacks\HD-StartLauncher.exe")
End Sub
Private Sub Button_Close_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Close.Click
Timer_ProcessCheck.Stop()
Process.Start("cmd.exe", "/c taskkill /IM HD-BlockDevice.exe /f")
Process.Start("cmd.exe", "/c taskkill /IM HD-Agent.exe /f")
Process.Start("cmd.exe", "/c taskkill /IM HD-LogRotatorService.exe /f")
Process.Start("cmd.exe", "/c taskkill /IM HD-UpdaterService.exe /f")
Me.Close()
End Sub
Private Sub Timer_ProcessCheck_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer_ProcessCheck.Tick
Dim oProcess As New Process()
Dim oStartInfo As New ProcessStartInfo("tasklist")
oStartInfo.CreateNoWindow = True
oStartInfo.UseShellExecute = False
oStartInfo.RedirectStandardOutput = True
oProcess.StartInfo = oStartInfo
oProcess.Start()
Dim sOutput As String
Using oStreamReader As System.IO.StreamReader = oProcess.StandardOutput
sOutput = oStreamReader.ReadToEnd()
End Using
If sOutput.Contains("HD-BlockDevice.exe") Then
Button_Close.Enabled = True
Else
Button_Close.Enabled = False
End If
End Sub
End Class
这篇关于杀死蓝栈的过程/结束过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!