Kill process started with System.Diagnostic.Process.Start(“FileName”)

后端 未结 6 1418
生来不讨喜
生来不讨喜 2021-02-05 22:48

I am trying to create an app that will perform actions on specific times (much like the Windows Task Scheduler). I am currently using Process.Start() to launch the file (or exe)

6条回答
  •  忘掉有多难
    2021-02-05 23:19

    Two ways:

    1-

    Process customProc = Process.Start("ExecutablePath", "Argument(s)");  
    customProc.Kill()
    

    2-

    Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("ProcessName")  
    For Each p As Process In pProcess
    p.Kill()
    Next
    

提交回复
热议问题