Solved

Creating infinite loop in VBS

Posted on 2007-04-11
6
5,486 Views
Last Modified: 2016-09-22
What might be the most compact instruction I could use to cause an infinite loop in vbs?
Thanks!
JohnD
0
Comment
Question by:johndarby
  • 3
  • 2
6 Comments
 
LVL 35

Expert Comment

by:mvidas
ID: 18890733
Hi John,

Not sure why you want to do this, but what about just:

For i = 1 to 10
 i = i - 1
Next

Matt
0
 
LVL 1

Author Comment

by:johndarby
ID: 18890906
Thanks Matt!
Is there a way to determine when the script engine has timed out with the script above?
0
 
LVL 35

Accepted Solution

by:
mvidas earned 500 total points
ID: 18890997
By default there is no timeout value, so it won't actually time out using just the code above.  You can set the number of seconds before timeout using     wscript.timeout=numberofseconds    but there is nothing notifying you when that is reached.

You can see what I mean by opening your task manager and sorting the processes in reverse alphabetical order. when this starts running you'll see wscript.exe in the list, and after it reaches the timeout value (10 seconds) it will quit. I'm echoing the timeout value so you can see it has the default value of 0 (no timeout) then you can see the change implemented:

wscript.echo wscript.timeout
wscript.timeout = 10
wscript.echo wscript.timeout
For i = 1 to 10
 i = i - 1
Next

Matt
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:johndarby
ID: 18891408
Thanks Matt; that's great!
0
 
LVL 35

Expert Comment

by:mvidas
ID: 18891448
Glad to help!
0
 

Expert Comment

by:Lokesh Natarajan
ID: 41810404
It is not working out for me. When I tried to compile the code above,it become not responding.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This is a little timesaver I have been using for setting up Microsoft Small Business Server (SBS) in the simplest possible way. It may not be appropriate for every customer. However, when you get a situation where the person who owns the server is i…
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…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

948 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

20 Experts available now in Live!

Get 1:1 Help Now