Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Probably a very simple answer but.... 1

Status
Not open for further replies.

NoCoolHandle

Programmer
Apr 10, 2003
2,321
US
I have been trying to figure out how to call a vb script file and pass a parameter to it but the answer isn't jumping at me...

e.g.

appendtofile.vbs 'new entry to log'

Thanks in advance


Rob
 
Dim Sh
Set Sh = WScript.CreateObject("WScript.Shell")
Sh.Run "appendtofile.vbs 'new entry to log'"

Hope This Help
PH.
 
Sorry I don't think I could have explained the problem well enough..

I need to execute the script from a command prompt and pass it a parameter during its execution..

in a batch file I would have used a %1 %2 %3 type syntax to pull the first second and third parameters out of an execution string..

I.e. the batch file could have been called run.bat and you could execute it as..

run rob tom john

and the batch file would have been able to use rob, tom and john as parameters inside it's execution..
internal systax would look something like

echo %1
echo %2
echo %3

and the output would be

rob
tom
john


Is there some type of equivilant syntax in vbscript?

 
In the batch file:
cscript appendtofile.vbs 'new entry to log'
In the script file:
Dim argv,i
Set argv = WScript.Arguments
For i = 0 To argv.Count -1
WScript.Echo argv(i)
Next

Hope This Help
PH.
 
Ahh.. that looks just like what the doctor ordered! THank you very much!


Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top