Guest User

fromITguyUdontLike

a guest
Dec 20th, 2015
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. strComputer = "."
  2.  
  3. Set objWMIService = GetObject("winmgmts:" _
  4.     & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
  5.     i = x
  6.     Do While i = x
  7.         Set colProcesses = objWMIService.ExecQuery _
  8.             ("Select * from Win32_Process Where Name = 'wordpad.exe'")
  9.  
  10.         If colProcesses.Count = 0 Then
  11.             'It does not exist do nothing
  12.         Else
  13.             For Each objProcess in colProcesses
  14.                
  15.                 objProcess.Terminate()
  16.                    
  17.                    
  18.                     Set colProcesses = objWMIService.ExecQuery _
  19.                      ("SELECT * FROM Win32_Process WHERE Name = 'notepad.exe'")
  20.                    
  21.                     For Each objProcess2 in colProcesses
  22.                      objProcess2.Terminate()
  23.                     Next
  24.                
  25.                 Dim objShell
  26.                 Set objShell = WScript.CreateObject( "WScript.Shell" )
  27.  
  28.                 objShell.Run("""C:\Windows\System32\notepad.exe""")
  29.                
  30.                 Set objShell = Nothing
  31.  
  32.             Next
  33.         End If
  34.  
  35. Loop
Add Comment
Please, Sign In to add comment