Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. ' Calls WshShell.Exec with c and kills the process tree after the specified timeout t
  2. ' Returns the created WshScriptExec object
  3. Function Exec(c, t)
  4. Dim s, e : Set s = CreateObject("WScript.Shell") : Set e = s.Exec(c)
  5. Do While e.Status = 0
  6. Call s.Run("waitfor /t 1 OneSecond", 0, True)
  7. t = t - 1
  8. If 0 >= t Then
  9. Call s.Run("taskkill /t /f /pid " & e.ProcessId, 0, True)
  10. Exit Do
  11. End If
  12. Loop
  13. Set Exec = e
  14. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement