Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 688

[RESOLVED] How can i kill all instances of "Wscript.exe" exept one that is started by my VBS ?

$
0
0
Hi ;)
Please i need some help to solve my issue !
so the question is : How can i kill all instances of "Wscript.exe" exept one that is started by my VBS ?
I made this script , but i get an error at line 19
PHP Code:

Set oWMISrvc GetObject("winmgmts:" _
"{impersonationLevel=impersonate}!\\.\root\cimv2")

sProcName Mid(wsh.fullnameInstrRev(wsh.fullname"\") + 1)

Set cProcesses = oWMISrvc.ExecQuery( _
"
select from win32_process where Name '" & sProcName & "'")

For Each oProcess in cProcesses
    If Instr(lcase(oProcess.Commandline), lcase(wsh.scriptname)) < 0 Then
        wsh.echo oProcess.Commandline
        wsh.echo wsh.scriptname
    else
        Process2kill = Mid(oProcess.CommandLine,InStr(oProcess.CommandLine,""" """) + 2)
        Process2kill = Replace(Process2kill,chr(34),"")
        msgbox Process2kill 
        Set colItems = GetObject("
winmgmts:").ExecQuery("Select from Win32_Process " _
        & "
where commandline like '" & Process2kill &"'",,48)
        For Each objItem in colItems 
            Wscript.Echo "
Terminating script with this CommandLine" & objItem.CommandLine
            objItem.Terminate()
        Next
    End If
Next
msgbox "
ok

Thank you !

Viewing all articles
Browse latest Browse all 688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>