Link to home
Start Free TrialLog in
Avatar of HackLife
HackLife

asked on

VBScript: How do I import another VBS file as an include?

VBScript: How do I import another VBS file as an include?

If there is a uniform way to do it, I would like to know how? If not, I would like to know if there is a back door way to perform this. Thanks.
Avatar of HackLife
HackLife

ASKER

Well, I figured it out, but I still would like to give the points away. I need to understand what are the difference between these:

Eval

ExecuteGlobal

Execute

and how to use them.

I found this in another board:

Include "somecode.vbs"

Sub Include(sCodeFile)
  Dim sCode
  with createobject("scripting.filesystemobject")
    sCode = .OpenTextFile(sCodeFile).ReadAll
  End With
  ExecuteGlobal sCode
End Sub
Why not just set the vbsfile as a Constant:

Dim wshell

Const VBSFILE = "Somefile.vbs"

Set wshell = CreateObject("WScript.Shell")

wshell.Run VBSFILE

Set wshell = Nothing
ASKER CERTIFIED SOLUTION
Avatar of lotsofish
lotsofish

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Because I'm including classes and "run" will not help any.