Solved

stop execution of vbs file

Posted on 2008-09-29
10
1,594 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
Comment Utility
WScript.Quit should do the trick
0
 

Author Comment

by:ankur3020
Comment Utility
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
Comment Utility
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
 
LVL 13

Expert Comment

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

Author Comment

by:ankur3020
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 13

Expert Comment

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

Author Comment

by:ankur3020
Comment Utility
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
Comment Utility
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
Comment Utility
thanks  for your guidance.
0
 

Author Comment

by:ankur3020
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now