|
-
May 30th, 2008, 02:18 PM
#1
Thread Starter
New Member
[RESOLVED] How do I run a .vbs?
I have a .vbs that I am trying to run. Right now the .vbs extension is associated with notepad on my computer, so if I double click it it just opens in notepad. How do I run the script?
Last edited by Hack; May 31st, 2008 at 04:47 AM.
Reason: Added RESOLVED to thread title and green resolved checkmark
-
May 30th, 2008, 03:33 PM
#2
Re: How do I run a .vbs?
A .vbs file can be one of two things: a "naked VBScript" WSH script or a VBScript include file for use in a .wsf, .htm, or .hta file. The default for a Shell open on a .vbs file is to open it in wscript.exe but this is often changed to cscript.exe on servers.
It is possible for some security software suites or local security policies to disable or remove wscript or cscript.
Assuming that is not the case you should be able to restore the Shell verb to its original state by right-clicking and selecting Open with... and choosing wscript.exe checking "always use the selected program..." Details vary by Windows OS.
You can also simply type:
wscript file.vbs ... from a command prompt.
-
May 30th, 2008, 03:34 PM
#3
Re: How do I run a .vbs?
Welcome to the Forums
ShellExecute the vbs file.
Code:
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Const SW_HIDE As Long = 0
Private Const SW_SHOWNORMAL As Long = 1
Private Const SW_SHOWMAXIMIZED As Long = 3
Private Const SW_SHOWMINIMIZED As Long = 2
Private Sub Command1_Click()
ShellExecute Me.hwnd, "open", "C:\Users\Public\myscript.vbs", vbNullString, "C:\", SW_SHOWNORMAL
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
May 30th, 2008, 03:42 PM
#4
Thread Starter
New Member
Re: How do I run a .vbs?
Thank you I have it working now.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|