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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| Option Explicit
Dim Ws,fso,Var1,Var2,Var3,Var4,Var5,Var6,Var7,Var8,Var9,Var10,Var11,Var12,MainArray,LogFile,i,OutPut,count
Set Ws = CreateObject("Wscript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Var1 = "Chrome.exe"
Var2 = "sidebar.exe"
Var3 = "BTSync.exe"
Var4 = "ISUSPM.exe"
Var5 = "ETDCtrl.exe"
Var6 = "jusched.exe"
Var7 = "vsnp2uvc.exe"
Var8 = "VProTray.exe"
Var9 = "tv_w32.exe"
Var10 = "TeamViewer.exe"
Var11 = "TeamViewer_Service.exe"
Var12 = "AthBtTray.exe"
MainArray = Array(Var1,Var2,Var3,Var4,Var5,Var6,Var7,Var8,Var9,Var10,Var11,Var12)
LogFile = Left(Wscript.ScriptFullName,InstrRev(Wscript.ScriptFullName, ".")) & "log"
count = 0
If fso.FileExists(LogFile) Then fso.DeleteFile LogFile
Set OutPut = fso.OpenTextFile(LogFile,8,True)
For i = LBound(MainArray) To UBound(MainArray)
Call Kill(MainArray(i))
Next
'Stopper le Service TeamViewer
Call MyService("TeamViewer9","Stop")
OutPut.WriteLine String(50,"*")
OutPut.WriteLine count & " Process were killed !"
OutPut.WriteLine String(50,"*")
If fso.FileExists(LogFile) Then
ws.run LogFile 'To show the LogFile
End if
'***********************************************************************************************
Sub Kill(MyProcess)
On Error Resume Next
Dim colItems,objItem
Set colItems = GetObject("winmgmts:").ExecQuery("Select * from Win32_Process " _
& "Where Name like '%"& MyProcess &"%' AND NOT commandline like '%" & wsh.scriptname & "%'",,48)
For Each objItem in colItems
count= count + 1
OutPut.WriteLine Mid(objItem.CommandLine,InStr(objItem.CommandLine,""" """) + 2)
objItem.Terminate(0)
If Err <> 0 Then
OutPut.WriteLine Err.Description
End If
Next
End Sub
'***********************************************************************************************
Sub MyService(strServiceName,State)
Dim objWMIService,colListOfServices,objService
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery("Select * from Win32_Service Where Name ='" & strServiceName & "'")
If State = "Start" Then
For Each objService in colListOfServices
If objService.state = "Stopped" Then
objService.StartService()
OutPut.WriteLine VbCrLF & String(50,"*") & VbCrLF & "Le Service : " & strServiceName & " a été demarré avec succés !"
End If
Next
ElseIF State = "Stop" Then
For Each objService in colListOfServices
If Not objService.state = "Stopped" Then
objService.StopService()
OutPut.WriteLine VbCrLF & String(50,"*") & VbCrLF &"Le Service : " & strServiceName & " a été arrêté avec succés !"
End If
Next
End if
End Sub
'*********************************************************************************************** |
Partager