Solved

Script responce to a message box

Posted on 2007-11-29
8
235 Views
Last Modified: 2010-04-16
I have a script created the looks like ths
Net Stop Advantage
When this script is executed I get a pop up box that asks me if i'm sure i want to stop the service while users are connected Yes or Cancel. Is there a way to include the responce Yes in a script..
0
Comment
Question by:CADRE308
  • 5
  • 3
8 Comments
 
LVL 13

Expert Comment

by:haim96
ID: 20376820
i wrote this simple VBS :
*******************************
set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Sleep 150000
WshShell.AppActivate "Desktop"
WshShell.SendKeys "{enter}"
********************************
save it as window.vbs in c:\

call the VBS after "Net Stop Advantage" by "cscript c:\window.vbs" for example
this should automatic press enter on OK (if it's the defualt key in the popup)

hope this work :)






*******************************
set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Sleep 150000
WshShell.AppActivate "Desktop"
WshShell.SendKeys "{enter}"
********************************

Open in new window

0
 

Author Comment

by:CADRE308
ID: 20376910
That should work fine if the default is "OK" but what do i substitute if the default responce is "Cancel"
0
 
LVL 13

Expert Comment

by:haim96
ID: 20376942
i will try to check for you...
but first, try to see if it's work, even for "cancel"
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:CADRE308
ID: 20377040
I will try it tonight and let you know in the morning.
Thanks,
0
 
LVL 13

Accepted Solution

by:
haim96 earned 500 total points
ID: 20377289
OK, here is update:
first note that you must change the "Desktop" to your window's title
so the script will focus on the right window.

if it's focused on the wrong button add the line :
WshShell.SendKeys "{tab}"
before the line:
WshShell.SendKeys "{enter}"
this should move the focus to the "YES" button and then it will send "ENTER".

note that the line :
WScript.Sleep 150000
is for creating delay, you can play with this and make it shorter if you want.

0
 
LVL 13

Expert Comment

by:haim96
ID: 20377480
and i almost forgot!
try to use PSservice from sysinternals, i didn't check it myself
but there is a chance that when you will stop process with it, it will just stop.

http://www.microsoft.com/technet/sysinternals/Processesandthreadsutilities.mspx?wt.svl=featured

if not, you can use pskill to kill the running process and the shut it down but
it's not recommanded in most cases.

i think i'm done with you ... :)
update me.
0
 

Author Comment

by:CADRE308
ID: 20381703
This worked like a charm. Thank You very much for all of the information. :-)
0
 
LVL 13

Expert Comment

by:haim96
ID: 20381772
cheers!  :)
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you considered what group policies are backwards and forwards compatible? Windows Active Directory servers and clients use group policy templates to deploy sets of policies within your domain. But, there is a catch to deploying policies. The…
This is a little timesaver I have been using for setting up Microsoft Small Business Server (SBS) in the simplest possible way. It may not be appropriate for every customer. However, when you get a situation where the person who owns the server is i…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question