VbScript AppActivate fails to bring focus to window

hi

the following script does the job (sends ESC to the app and causes it to exit) IF i dont focus on a different window between the moment i run the script and the app is finished starting. if i do select another window between running the script and the app done loading, i can see the title bar for the foremost window (login) on that app blinking every 1 second, but it doesnt not close the app and it loops there until i manually focus back on the app.

when the app starts it opens up a login box named "login". the app is named "store operations manager". it doesnt matter if i bring the focus to the main window or the child window, because it defaults to the login window and as soon as i manually bring focus to it the ESC gets sent and the app exits. the same problem occurs when the script is run as a scheduled task (when there is nobody manually switching focus as i am the only one who logins to this win2003 SBS machine)

Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run """C:\Program Files\Microsoft Retail Management System\Store Operations\SOMANAGER.exe"""
Do Until Success = True
    Success = objShell.AppActivate("Store Operations Manager")
    Wscript.Sleep 1000
Loop
objShell.SendKeys ("{ESC}")

what is the problem here?
thanks
Set objShell = nothing
crashnetAsked:
Who is Participating?
 
GranModCommented:
Closed, 500 points refunded.
GranMod
The Experts Exchange
Community Support Moderator of all Ages
0
 
Leo EikelmanDirector, IT and Business DevelopmentCommented:
maybe the name is too long.  What if u do

<<<<<<<<< SNIP >>>>>>>>>>>
..................
  Success = objShell.AppActivate("Store Op")
  Wscript.Sleep 1000
Loop
objShell.SendKeys "{ESC}"


Cheers,

Leo


0
 
Leo EikelmanDirector, IT and Business DevelopmentCommented:
I dont know if this is of use but it was posted on msdn

http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B109262
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
crashnetAuthor Commented:
i tried to use "store" and "login". i only need one double quote character on each side, right? cause for the path i needed THREE on each side

i dont think the msdn article applies in my case. i am using the latest version of wscript and vbscript on windows 2003
0
 
Leo EikelmanDirector, IT and Business DevelopmentCommented:
yeah it should be only one set of double quotes

Leo
0
 
crashnetAuthor Commented:
i found a workaround: i am killing the process instead of sending {ESC} to it and it accomplishes my goal.

thanks to all,
crashnet
0
 
crashnetAuthor Commented:
i would like to get a refund on this Q. i found my answer thru another forum.

thanks

crashnet
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.