Solved

stop execution of vbs file

Posted on 2008-09-29
10
1,607 Views
Last Modified: 2012-05-05
execution of vbs file stops when i press shift+A+B in same flow. Please provide code.
0
Comment
Question by:ankur3020
  • 5
  • 5
10 Comments
 
LVL 13

Assisted Solution

by:Michael_D
Michael_D earned 125 total points
ID: 22598949
WScript.Quit should do the trick
0
 

Author Comment

by:ankur3020
ID: 22607165
i want to stop execution on pressing of some keys in combination. pls provide code accordingly.
0
 
LVL 13

Assisted Solution

by:Michael_D
Michael_D earned 125 total points
ID: 22607791
It would help a lot if you provide more info on what are you doing (infinite loop, long process etc.)
Anyway the VBS doesn't listen for keyboard interceptions unless you tell him to read key from the keyboard.  Something like attached script that ask user to enter a decimal number and convert it to hex until 0 is entered.
But this way script paused until user enters the number which might be not appropriate in your situation.

Also you might want to chech this solution that actually used abilities of internet explorer to handle keystrokes:
http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.scripting.wsh&tid=5183b9f4-cde1-4caa-adcb-a77275beb900&cat=&lang=en&cr=US&sloc=&p=1


Do While true
Wscript.StdOut.Write "Enter a Decimal Number (Enter 0 to exit): "
strDecimal = Wscript.StdIn.ReadLine
 
if strDecimal="0" then
   Wscript.StdOut.WriteLine "Exiting..."
   Wscript.Quit
Else
Wscript.StdOut.WriteLine strDecimal & " is equal to " & _
 Hex(strDecimal) & " in hex."
end if
 
Loop 

Open in new window

0
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!

 
LVL 13

Expert Comment

by:Michael_D
ID: 22607816
BTW did you try stop the execution by pressing CTRL+C?
0
 

Author Comment

by:ankur3020
ID: 22610952
strange can clt+C stop the execution of vbs file? if yes tell me how to prevent it.

any way please note, there is a file with infinite loop i.e. which once started will keep on running. now i want to add some keys or some coding which help me to stop it when required. i do not want any inputbox to be displayed for me . i want if some key is pressed with combination of some other key execution stops. pls amend the above code as required.
0
 
LVL 13

Expert Comment

by:Michael_D
ID: 22611397
If your vbs will run in background with no user interface than your request is not possible
0
 

Author Comment

by:ankur3020
ID: 22611575
ok, but can we do something like the inputbox will raise if i press some special key  all  till time vbs file run in background
0
 
LVL 13

Expert Comment

by:Michael_D
ID: 22611624
no its impossible.
I have read all questions you posted here. it seems like you want to implement some sort of security but you choose wrong tools and methods to do it. If you'll explain what is your problem and what you want to achieve I am sure you will get much more helpful comments
0
 

Accepted Solution

by:
ankur3020 earned 0 total points
ID: 22694668
thanks  for your guidance.
0
 

Author Comment

by:ankur3020
ID: 22768886
i run ur attached code,it is giving error pls check. error at line 3 , invalid handle
Do While true
Wscript.StdOut.Write "Enter a Decimal Number (Enter 0 to exit): "
strDecimal = Wscript.StdIn.ReadLine
 
if strDecimal="0" then
   Wscript.StdOut.WriteLine "Exiting..."
   Wscript.Quit
Else
Wscript.StdOut.WriteLine strDecimal & " is equal to " & _
 Hex(strDecimal) & " in hex."
end if
 
Loop 

Open in new window

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

761 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