Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Close an application using VBScript

Tags:

vbscript

I was trying to open and close an application. I tried like this:

Dim App1 
Set App1 = CreateObject("WScript.Shell")
App1.Run("firefox")
App1.Quit

Firefox will open, but it will not close.

Error message:

object doesn't support this property or method

I referred InDesign Scripting how to quit application (not document)

Please tell me the procedure to close the application.

like image 574
user1915934 Avatar asked Mar 12 '13 07:03

user1915934


1 Answers

If you want to be able to terminate a process that way you need to use the Exec method instead of the Run method.

Set ff = CreateObject("WScript.Shell").Exec("firefox")
'you do stuff
ff.Terminate
like image 116
Ansgar Wiechers Avatar answered Sep 22 '22 18:09

Ansgar Wiechers