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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling a vbscript from a vbscript 1

Status
Not open for further replies.

SlakeB

MIS
Jun 15, 2005
40
US
Is it possible to call a vbscript file from within another vbscript file without using the DOS shell?
 
You can read the file into a variable then .Execute it.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
So would I do something like this?:
Code:
Set Cmd = Server.CreateObject("ADODB.Command")
sVBToRun = "externalScript.vbs"
Cmd.Execute(sVBToRun)
 
No, look at the ExecuteGlobal function and the .Readall method of the text stream object. This is a generic function that I wrote so that I could pull classes into a script from an external file. It should get you going:

Code:
Sub AddClass(strClassFile)
    Dim oFSO, oFile, strFile

    Set oFSO = CreateObject ("Scripting.FileSystemObject")
    Set oFile = oFSO.OpenTextFile(strClassFile)
    strFile = oFile.ReadAll
    oFile.close
    Set oFso = Nothing
    Set oFile = Nothing
    ExecuteGlobal strFile
End Sub

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top