Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Script responce to a message box

Posted on 2007-11-29
8
Medium Priority
?
241 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The password reset disk is often mentioned as the best solution to deal with the lost Windows password problem. In Windows 2008, 7, Vista and XP, a password reset disk can be easily created. But besides Windows 7/Vista/XP, Windows Server 2008 and ot…
This article will show, step by step, how to integrate R code into a R Sweave document
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

721 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