杀死bluestacks的进程/结束进程

时间:2015-06-13 16:03:53

标签: process kill bluestacks

我正在尝试制作一个可以打开和关闭bluestacks应用程序的程序。关闭意味着完全退出应用程序。因为即使您退出bluestacks应用程序,该过程也将重新启动。 我正在尝试杀死的进程是:

  1. “HD-BlockDevice.exe”
  2. “HD-Agent.exe”
  3. “HD-LogRotatorService.exe”
  4. “HD-UpdaterService.exe”
  5. 当我手动终止第一个进程时,另一个进程将关闭,除了2~3个进程。每次关闭应用程序时杀死四个进程都很痛苦,所以我创建了这个进程。 这是我的代码

    std::string str = "hello";
    char const& front_ref = static_cast<std::string const&>(str).front();
    str[0] = 'x';
    std::cout << front_ref; // prints x
    

    我的问题是:

    1. 我的流程检查工作无法工作(当流程已经存在时,它不启用关闭按钮)
    2. 我查找的任何进程终止都不起作用(这些是我在代码中发表的评论)

1 个答案:

答案 0 :(得分:1)

从不同的角度看后,我终于找到了一个通过命令提示符杀死它的想法......在网上看了很多怎么做之后我终于找到了一个让它起作用的答案... < / p>
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