Ma Question : Comment peut-on tuer toutes les instances de "Wscript.exe" sauf une qui est lancée par mon script VBS ?
J'ai commencé à faire un petit script, mais je suis bloqué au niveau de la ligne 19 Erreur de syntaxe
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Set oWMISrvc = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\.\root\cimv2")
 
sProcName = Mid(wsh.fullname, InstrRev(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"