Solved

stop execution of vbs file

Posted on 2008-09-29
10
1,599 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

776 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