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.
beeravallyAsked:
Who is Participating?
 
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
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.