lundi 29 juin 2015

Close programs with Vbs one click.

I am trying to get my script to loop through the if statment(s) and close the programs if they are open. However with what I have now I am only able to close the programs in the if statement by clicking the script twice. I suspect I may need a different loop but im not sure which one. This is what I have now.

Set oShell = CreateObject("WScript.Shell") 
Do 
if oShell.AppActivate("Untitled - Notepad") then
   WScript.Sleep 500
   oShell.SendKeys "%{F4}"

end if

if oShell.AppActivate("Cisco Packet tracer") then
   WScript.Sleep 500
   oShell.SendKeys "%{F4}"

end if

exit do
loop

Aucun commentaire:

Enregistrer un commentaire