Solved

Script responce to a message box

Posted on 2007-11-29
8
232 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
Comment Utility
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
Comment Utility
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
Comment Utility
i will try to check for you...
but first, try to see if it's work, even for "cancel"
0
 

Author Comment

by:CADRE308
Comment Utility
I will try it tonight and let you know in the morning.
Thanks,
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 13

Accepted Solution

by:
haim96 earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
This worked like a charm. Thank You very much for all of the information. :-)
0
 
LVL 13

Expert Comment

by:haim96
Comment Utility
cheers!  :)
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

When you upgrade from Windows 8 to 8.1 or to Windows 10 or if you are like me you are on the Insider Program you may find yourself with many 450MB recovery partitions.  With a traditional disk that may not be a problem but with relatively smaller SS…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

771 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now