Advertisement
Guest User

Untitled

a guest
May 5th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. Set objShell = WScript.CreateObject("WScript.Shell")
  2.  
  3. rv = objShell.Run("pathtoapplication.exe", 1 , True)
  4. If rv <> 0 Then
  5. MsgBox "Failed : " & rv
  6. End If
  7. WScript.Sleep 120000
  8. objShell.Run "taskkill /im pathtoapplication.exe"
  9.  
  10. Set objShell = Nothing
  11.  
  12. Option Explicit
  13. Dim Title,objShell,rv,ProcessPath,ProcessName
  14. Title = "Launching and killing application using Vbcript"
  15. Set objShell = CreateObject("WScript.Shell")
  16. ProcessPath = "C:Windowssystem32Calc.exe"
  17. rv = objShell.Run(DblQuote(ProcessPath),1,False)
  18. If rv <> 0 Then
  19. MsgBox "Failed : " & rv
  20. End If
  21. Set objShell = Nothing
  22. WScript.Sleep 12000
  23. ProcessPath = Split(ProcessPath,"")
  24. ProcessName = ProcessPath(UBound(ProcessPath))
  25. Msgbox "The Process named "& DblQuote(ProcessName) &" is being to be killed now !",_
  26. vbExclamation,Title
  27. Call Kill(ProcessName)
  28. '****************************************************
  29. Sub Kill(ProcessName)
  30. Dim Ws,Command,Execution
  31. Set Ws = CreateObject("Wscript.Shell")
  32. Command = "cmd /c Taskkill /F /IM "& DblQuote(ProcessName) &""
  33. Execution = Ws.Run(Command,0,True)
  34. Set Ws = Nothing
  35. End Sub
  36. '****************************************************
  37. Function DblQuote(Str)
  38. DblQuote = Chr(34) & Str & Chr(34)
  39. End Function
  40. '****************************************************
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement