Free since 2005 · No login required
AT

Academic Tutorials

Learn at your own pace

site-mobile-top-banner · 320x50

How to Write a General VBScript

Added 28 Jul 2008

Things You’ll Need:

  • Windows Operating System (98 or Newer)
  • Notepad (application)
  • Knowledge of Command prompt
  • Some knowledge of a scripting ;anguage
  • Microsoft Visual Studio.Net Software (preferred)
    Step1
    Open Notepad. You can use this to write and edit the script.
    Step2
    Start each script with one specific line: Option Explicit.
    Step3
    Directly under the Option Explicit line you will need to declare your variables. You do this by using the DIM command. A variable is basically a nickname for information that is stored in a script.
    Step4
    Leave a space and then begin the Reference section of the script. The Reference section is where you assign values to the variables from Step 3. Simply state the variable, followed by an equal sign, and then the value of the variable.
    Step5
    Leave another space and begin the Worker section of the script. The Worker section is where the variables and references from Step 3 and 4 begin to get busy working. The use of the Set command will be found in this section of the script.
    Step6
    Leave a final space and begin the Output section of the script. The Output section is where the script will be told to echo results to the user or to a log file. This is where the “WScript.Echo” command will come into play.
    Step7
    After completion of the script save the script as a .vbs file. Once saved, you have several options of running the script. Some of the options available are double-clicking the file, using Command prompt to run the script with the CScript command, dragging and dropping the file into Command prompt, or running it through Visual Studio to check for errors.