VBScript: Restart a script automatically

Posted on 2006-05-09
Last Modified: 2012-06-27

My VBScript should run constantly on a server (Picking and mailing files).
So my question is:
What do I have to write at the end of my script, so that it will restart itself?

Thank you very much!
Question by:arthrex
    LVL 85

    Accepted Solution

    While True

        ' your code in here....    

        ' optional pause before "restarting"....
        WScript.Sleep 5000 ' (max is 32,767 --> approx 30 seconds)


    Author Comment


    That's great thank you very much!!

    One last question. Why do I have to declare a constant outside the While-Loop?
    (if I do so in the loop, it's throwing the error: Name already declared)

    But I'm able to declare variables inside the loop?!
    LVL 85

    Expert Comment

    by:Mike Tomlinson
    Because a constant can't be changed...and if the declaration is inside the loop it's like your trying to set the constant to a different value when the line is hit again.


    Author Comment


    thank you very much!

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
    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…

    746 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

    12 Experts available now in Live!

    Get 1:1 Help Now