我使用VB.NET开发一个可以执行某些.exe文件(由我创建)的Web应用程序,该文件将在服务器上运行并继续运行直到操作结束。
有时候,exe文件变得“陷入困境”。我无法做任何事情,只能从服务器上的任务管理器中删除它。
问题是,在执行另一个exe文件之前,我检查是否有一个已经运行的文件,并且我阻止了可能的" double"执行相同的程序,以便用户可以等待很长时间。
我用它来运行exe:
ProgrammaDaEseguire = Server.MapPath("/Batch") & "\my_program.exe"
Public Function RunSchedulatore(ByVal ProgrammaDaEseguire As String,
ByVal IdSchedulatore As Integer) As Boolean
Try
Dim Proc As System.Diagnostics.Process = New System.Diagnostics.Process()
Proc.StartInfo.FileName = ProgrammaDaEseguire
Proc.StartInfo.Arguments = IdSchedulatore
Proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden
Proc.StartInfo.UseShellExecute = False
Proc.Start()
RunSchedulatore = True
Catch ex As Exception
writeLog
RunSchedulatore = False
End Try
End Function
有什么方法可以杀死服务器上正在运行的进程吗?
我能够终止在我的客户端上运行的进程,但我不确定我是否可以在服务器端终止该进程。