This article was co-authored by wikiHow staff writer, Nicole Levine, MFA. Nicole Levine is a Technology Writer and Editor for wikiHow. She has more than 20 years of experience creating technical documentation and leading support teams at major web hosting and software companies. Nicole also holds an MFA in Creative Writing from Portland State University and teaches composition, fiction-writing, and zine-making at various institutions.
This article has been viewed 31,976 times.
Learn more...
This wikiHow teaches you how to run a Visual Basic script on a Windows PC. Visual Basic is a Windows-specific programming language, so you'll only be able to run your script using Windows.
Steps
Using the Windows Command Prompt
-
1Open the Command Prompt. An easy way to do this is to press Windows key + S to open the search bar, type command into the bar, and then click Command prompt in the search results.
- You may also be able to open the command prompt by pressing Windows key + X and selecting Command prompt. If you don't see this option there, you can select PowerShell –the command we'll be using will work in both the standard command prompt and PowerShell.[1]
-
2Navigate to the folder where the script is located. You can use the cd command to do this.
- For example, if the script is saved to C:\Windows\Scripts, type cd C:\Windows\Scripts and press Enter.
- The name of your script usually ends with the .VBS file extension.
Advertisement -
3Type cscript scriptname.vbs and press ↵ Enter. Replace scriptname.vbs with the name of the script you want to run. This displays the output of the script in the window.[2]
Using the Run Dialog
-
1Press ⊞ Win+R. Pressing Windows key + R' opens the Run dialog, which allows you to select and run any script or program.
-
2Click Browse. This opens the file browser.
-
3Select your script and click Open. If you don't see your script, click the drop-down menu at the bottom-right corner and select All files instead.
- The script will usually end with the *.VBS file extension.
-
4Click OK. This runs the script.
Using Windows Explorer
-
1Press ⊞ Win+E to open the File Explorer. This displays a list of files on your PC.
-
2Navigate to your script. The script likely ends with the .VBS file extension.[3]
-
3Double-click the script. This runs the Visual Basic script.
- If the script is a console script, it will open a command prompt window and display the output.[4]
References
- ↑ https://www.techwalla.com/articles/how-execute-vbs-script
- ↑ https://docs.microsoft.com/en-us/previous-versions/windows/desktop/indexsrv/running-a-visual-basic-scripting-edition-query
- ↑ https://www.geeksforgeeks.org/how-to-make-save-and-run-a-simple-vbscript-program/
- ↑ https://docs.microsoft.com/en-us/visualstudio/get-started/visual-basic/tutorial-console?view=vs-2019
About This Article
1. To run a script from the command prompt, use "cscript scriptname.
2. To run a script from Windows Explorer, double-click the script.
3. To run the script from the Run dialog, open the Run dialog, browse for the script, and click OK.