Solved

Script responce to a message box

Posted on 2007-11-29
8
234 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Welcome to my series of short tips on migrations. Whilst based on Microsoft migrations the same principles can be applied to any type of migration. My first tip Migration Tip #1 – Source Server Health can be found here: http://www.experts-exchang…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
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)
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

803 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