Hi,
I want to kill the running batch file process with another batch file.
Thanks
Kill Batch fill process from another batch file
Moderator: DosItHelp
Re: Kill Batch fill process from another batch file
One possible way is by getting the batch file PID - viewtopic.php?f=3&t=6133
save it to temp file and then kill it from another batch
save it to temp file and then kill it from another batch
Re: Kill Batch fill process from another batch file
npocmaka_ wrote:One possible way is by getting the batch file PID - viewtopic.php?f=3&t=6133
save it to temp file and then kill it from another batch
Ok Thanks
Re: Kill Batch fill process from another batch file
Hi
You can also give a try with this vbscript
You can also give a try with this vbscript
Code: Select all
Option Explicit
Call KillProcessbyName("MyBatchFileName.bat")
'**********************************************************************************************
Sub KillProcessbyName(FileName)
On Error Resume Next
Dim WshShell,strComputer,objWMIService,colProcesses,objProcess
Set WshShell = CreateObject("Wscript.Shell")
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery("SELECT * FROM Win32_Process")
For Each objProcess in colProcesses
If InStr(objProcess.CommandLine,FileName) > 0 Then
If Err <> 0 Then
MsgBox Err.Description,VbCritical,Err.Description
Else
objProcess.Terminate(0)
End if
End If
Next
End Sub
'**********************************************************************************************
Re: Kill Batch fill process from another batch file
Hackoo wrote:Hi
You can also give a try with this vbscriptCode: Select all
Option Explicit
Call KillProcessbyName("MyBatchFileName.bat")
'**********************************************************************************************
Sub KillProcessbyName(FileName)
On Error Resume Next
Dim WshShell,strComputer,objWMIService,colProcesses,objProcess
Set WshShell = CreateObject("Wscript.Shell")
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery("SELECT * FROM Win32_Process")
For Each objProcess in colProcesses
If InStr(objProcess.CommandLine,FileName) > 0 Then
If Err <> 0 Then
MsgBox Err.Description,VbCritical,Err.Description
Else
objProcess.Terminate(0)
End if
End If
Next
End Sub
'**********************************************************************************************
Thank you.
I have added this Check line in my batch file. Then I create the killmonitoring.txt file from another batch file if require and eventually my first batch file check it and exit the run nicely.
Code: Select all
if exist KillMonitoring.txt (exit)
Thanks