How to Execute VBS Script

Techwalla may earn compensation through affiliate links in this story. Learn more about our affiliate and product review process here.
VBS allows you to execute script based commands on Windows.
Image Credit: TommL/E+/GettyImages

A VBS script uses Visual Basic Scripting Codes to execute script based commands on Windows operating systems. The VBS Script language system is handy because scripts are easily written and executed in text based editors and Explorer. The VBScript system has evolved over time to serve a wide variety of functions for web developers and administrators and it continues to serve many users on the Windows OS.

Advertisement

What Is VBS Script?

Video of the Day

The purpose and intention of VBS scripts began for web developers working in the Microsoft framework. Eventually, web administrators realized the value of VBScripts and began using the scripts as automation tools. It was a major step up from the old batch language tools used and it popularized VBS immensely. The ability to save scripts for specific tasks and to access and run these scripts in a matter of seconds was a major time saver for developers and administrators.

Advertisement

Video of the Day

Windows Notepad is a common means of writing scripts for execution, because using a text based application makes the script writing convenient. The script itself however must be written flawlessly to function as intended. Save and label the text based VBS scripts into specifically labeled VBS files for easy access. Using the file name as a pathway for quick execution is a common method of launch VBS Script execution.

Advertisement

VBS was ultimately made to function with Explorer and versions 5.0 and 5.5 increased capabilities to include expressions, classes and with statements. Developers and web administrators use VBS Script language to perform specific tasks and to implement changes and adjustments to the system as a whole.

Advertisement

Execute a VBS File

Open Windows Explorer or a script specific execution program like PowerShell or Windows Script Host. In Explorer, type the script location into the address bar to access the script. For example, a folder labeled "Scripts" in the C drive will yield a C:\Scripts for the path to that specific folder. Double click on the specific VBS Script you want to run and it the process will execute.

Advertisement

Advertisement

When using a script execution tool, copy and paste from Notepad or utilize the pathway process to run the scripts. Always double check to ensure you are selecting the correct script because running the wrong script can cause damage to the system. Running VBS Scripts is convenient for developers and web administrators who are using the same saved scripts repeatedly.

Advertisement

In PowerShell, running the script is exceptionally easy. Simply type cscript to run your script. PowerShell is connected to your working directory and it will quickly pull the script with the matching file name. Take extra caution to access the correct file while using this process.

Alternative Script Methods

While running direct through Explorer or a script command application is easy and common, running through Windows Script Host is a good option as well. The program uses a dialogue box for quick script access and execution in the specific style. On Windows NT and Windows 2000 operating systems (but not more recent ones), you can type the script directly on the command line to execute.

Advertisement

Using this system, you can run scripts using the default engine, which is Explorer. This follows the same process as the previous section where you write a path for the script in Explorer. You can also run VBS Scripts using WScript.exe by clicking Start followed by Run. Type the file path into the Open field then click OK to open and run the script.

Advertisement

All of these methods are essentially using a similar approach to access and run the script. The only big difference lies in the program chosen to execute VBS Scripts, which is really a matter of personal preference.

Advertisement

Advertisement

references

Report an Issue

screenshot of the current page

Screenshot loading...