Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

stop execution of vbs file

Posted on 2008-09-29
10
Medium Priority
?
1,630 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 500 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 500 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

886 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