Solved

stop execution of vbs file

Posted on 2008-09-29
10
1,610 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
[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
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

739 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