Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Set objShell = WScript.CreateObject("WScript.Shell")
- rv = objShell.Run("pathtoapplication.exe", 1 , True)
- If rv <> 0 Then
- MsgBox "Failed : " & rv
- End If
- WScript.Sleep 120000
- objShell.Run "taskkill /im pathtoapplication.exe"
- Set objShell = Nothing
- Option Explicit
- Dim Title,objShell,rv,ProcessPath,ProcessName
- Title = "Launching and killing application using Vbcript"
- Set objShell = CreateObject("WScript.Shell")
- ProcessPath = "C:Windowssystem32Calc.exe"
- rv = objShell.Run(DblQuote(ProcessPath),1,False)
- If rv <> 0 Then
- MsgBox "Failed : " & rv
- End If
- Set objShell = Nothing
- WScript.Sleep 12000
- ProcessPath = Split(ProcessPath,"")
- ProcessName = ProcessPath(UBound(ProcessPath))
- Msgbox "The Process named "& DblQuote(ProcessName) &" is being to be killed now !",_
- vbExclamation,Title
- Call Kill(ProcessName)
- '****************************************************
- Sub Kill(ProcessName)
- Dim Ws,Command,Execution
- Set Ws = CreateObject("Wscript.Shell")
- Command = "cmd /c Taskkill /F /IM "& DblQuote(ProcessName) &""
- Execution = Ws.Run(Command,0,True)
- Set Ws = Nothing
- End Sub
- '****************************************************
- Function DblQuote(Str)
- DblQuote = Chr(34) & Str & Chr(34)
- End Function
- '****************************************************
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement