I need some help w/ a possible VBScript for closing an application
properly.

Here is the situation:

I need to do a backup of a very odd application. When backup's occur,
all users must be out of that application. The only sticky part here
is the application is very fussy as to how it has to be closed. If it
is closed improperly, it will not allow the backups to occur.

What I would like help with:

vbs that warns users that they are going to be logged off of
application 'Z' in 'x' minutes w/ a 5 minute reminder and then makes
winoac.exe (application) active and starts sending the logout key
sequence (just several esc keys).

Because my knowledge of vbs (or any kind of scripting) is so minimal
I'm embarrassed to post what I have thus far (which is actually
wscript inside of vbs). Any help that you all can provide would be
great!

--script--

Option Explicit

Dim objShell

'Time out option in seconds

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

'Bring application active
objShell.AppActivate "winoac"

'Sending messages
objShell.Popup "You will be logged off in 15 seconds", 5
wscript.sleep (1000)
objShell.Popup "You will be logged off in 10 seconds", 5
wscript.sleep (1000)
objShell.Popup "You will be logged off in 5 seconds", 5
wscript.sleep (1000)
objShell.Popup "You Are being logged off!", 5

'Bring Application Active
objShell.AppActivate "winoac.exe"

'Send 1st ESC key & Sleep
objShell.SendKeys "{ESC}"
wscript.sleep (1000)

'Send 2nd ESC key & Sleep
objShell.SendKeys "{ESC}"
wscript.sleep (1000)

'Send 3rd ESC key & Sleep
objShell.SendKeys "{ESC}"
wscript.sleep (1000)

'Send 4th ESC key & Sleep
objShell.SendKeys "{ESC}"
wscript.sleep (1000)

'Send 5th ESC key & Sleep
objShell.SendKeys "{ESC}"
wscript.sleep (1000)

'Send 6th ESC key & Sleep
objShell.SendKeys "{ESC}"
wscript.sleep (1000)

'Send 7th ESC key & Sleep
objShell.SendKeys "{ESC}"
wscript.sleep (1000)

Set objShell = Nothing

WScript.Quit 0

Thanks again,

Re: Closing application properly by Jeremy

Jeremy
Wed May 09 16:40:07 CDT 2007

Try using AutoIt. It is pretty easy to use and can do all keystroke
generation you like.
http://www.autoitscript.com/autoit3/

"mjg" <grahammj@gmail.com> wrote in message
news:1178723346.530823.181770@y5g2000hsa.googlegroups.com...
>I need some help w/ a possible VBScript for closing an application
> properly.
>
> Here is the situation:
>
> I need to do a backup of a very odd application. When backup's occur,
> all users must be out of that application. The only sticky part here
> is the application is very fussy as to how it has to be closed. If it
> is closed improperly, it will not allow the backups to occur.
>
> What I would like help with:
>
> vbs that warns users that they are going to be logged off of
> application 'Z' in 'x' minutes w/ a 5 minute reminder and then makes
> winoac.exe (application) active and starts sending the logout key
> sequence (just several esc keys).
>
> Because my knowledge of vbs (or any kind of scripting) is so minimal
> I'm embarrassed to post what I have thus far (which is actually
> wscript inside of vbs). Any help that you all can provide would be
> great!
>
> --script--
>
> Option Explicit
>
> Dim objShell
>
> 'Time out option in seconds
>
> Set objShell = WScript.CreateObject("WScript.Shell")
>
> 'Bring application active
> objShell.AppActivate "winoac"
>
> 'Sending messages
> objShell.Popup "You will be logged off in 15 seconds", 5
> wscript.sleep (1000)
> objShell.Popup "You will be logged off in 10 seconds", 5
> wscript.sleep (1000)
> objShell.Popup "You will be logged off in 5 seconds", 5
> wscript.sleep (1000)
> objShell.Popup "You Are being logged off!", 5
>
> 'Bring Application Active
> objShell.AppActivate "winoac.exe"
>
> 'Send 1st ESC key & Sleep
> objShell.SendKeys "{ESC}"
> wscript.sleep (1000)
>
> 'Send 2nd ESC key & Sleep
> objShell.SendKeys "{ESC}"
> wscript.sleep (1000)
>
> 'Send 3rd ESC key & Sleep
> objShell.SendKeys "{ESC}"
> wscript.sleep (1000)
>
> 'Send 4th ESC key & Sleep
> objShell.SendKeys "{ESC}"
> wscript.sleep (1000)
>
> 'Send 5th ESC key & Sleep
> objShell.SendKeys "{ESC}"
> wscript.sleep (1000)
>
> 'Send 6th ESC key & Sleep
> objShell.SendKeys "{ESC}"
> wscript.sleep (1000)
>
> 'Send 7th ESC key & Sleep
> objShell.SendKeys "{ESC}"
> wscript.sleep (1000)
>
> Set objShell = Nothing
>
> WScript.Quit 0
>
> Thanks again,
>