Solved

Script responce to a message box

Posted on 2007-11-29
8
240 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
Independent Software Vendors: 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!

 

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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
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.
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…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

617 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