troubleshooting Question

How do I launch an application and close it after a few seconds?

Avatar of PeterdeB
PeterdeBFlag for Netherlands asked on
Visual Basic Classic
4 Comments1 Solution150 ViewsLast Modified:
Hi my dear friends!

I would like to launch an application and close it after a few this code seemed to work. Only after editing the wrong file ( I was editing a backup file while testing the original) it stopped working. Note: launching the application is no problem, only closing down is a problem. I tried several sleep arguments but without success. I just can't close the application just like I did a few hours ago.

'Beginning of code

Set WshShell = WScript.CreateObject("WScript.Shell")

' Launch the application
' Wait for the application
' Send ALT F4 to close the application
WshShell.Run """" & App & """", 1, True
WScript.Sleep 200
WshShell.SendKeys "%{F4}"    

'End of all hope :)

Kind regards,


Ps working samples please! And if you need more info, please ask. I will be firing some more questions about this issue so that is why I do not post all the code at once.

Ravi Singh
Senior Software Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros