• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1080
  • Last Modified:

vb script

hai,
i write a vb script program and i named that file as "test.vbs".then how can i run that test.vbs file.
0
beeravally
Asked:
beeravally
4 Solutions
 
ColosseoCommented:
hi

there are two straight forward ways

1. Just double click the file to run it
2. Open a command prompt and enter the file path and name to run it
  For example if the file is in the temp folder of the c drive use

c:\temp\test.vbs at the command prompt

HTH

Scott
0
 
mladenoviczCommented:
Start->Run

wscript c:\test.vbs
0
 
Ryan ChongCommented:
or using shellexecute api, like:

Public 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

Public Function StartDoc(ByVal FileName As String, Optional CommandLine As String = "") As Long
    StartDoc = ShellExecute(0&, "Open", FileName, CommandLine, vbNullString, 1)
End Function

then:

StartDoc "c:\test.vbs"
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
EDDYKTCommented:
Or from code

Dim wshShell
Set wshShell = CreateObject("WScript.Shell")
wshShell.Run "c:\yourvbs.vbs", , True
Set wshShell = Nothing
0
 
Ryan ChongCommented:
I think mine only works inside Visual Basic, but not for pure .vbs file, so my suggestion:

Accept EDDYKT's comment as the answer

cheers
0
 
Ryan ChongCommented:
After re-read the question:
>>i write a vb script program and i named that file as "test.vbs".then how can i run that test.vbs file.
hmm..  am i contribute some here?? Will it fair that split among 3 of us, anyway, i will be happy with the final decision, cheers 8-)
0
 
GPrentice00Commented:
question was how to run .vbs file, not how to run .vbs file inside .vbs file.
Split between first two major concepts: 1) command line interactively  2) shell calls programmatically.

0
 
Ryan ChongCommented:
Hi GPrentice00,

EDDYKT's solution works in both .vbs and inside Visual Basic, so it's fair enough to give some points for EDDYKT for his contribution here.

cheers
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now