Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vbscript-terminating process instance

I'm writing a script that runs an external program, and after a while terminates it, the relevant code section looks like this:

Set objshell=createObject("Wscript.Shell")
objShell.run ""app.exe""
objShell.run ""app.exe""
WScript.Sleep(5000)

strWmiq = "select * from Win32_Process where name='app.exe'" 
Set objQResult = objWmi.Execquery(strWmiq)
    For Each objProcess In objQResult 
        intRet = objProcess.Terminate(1)
    Next 

What I want to do is to close each of the instances of app.exe after different sleep times, any ideas how to do that?

like image 841
user1262882 Avatar asked Jul 19 '26 01:07

user1262882


1 Answers

Use WScript.Shell's .Exec method to get a WshScriptExec objects for each session/run/instance of app.exe and .Terminate them at your leisure (and risk). See Terminate Method (WshScriptExec)

like image 59
Ekkehard.Horner Avatar answered Jul 21 '26 21:07

Ekkehard.Horner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!