1
May/070
May/070
VBS Includes
I used the code to in a script to source out some code from a realy big script. I lost it and didn’t find again. Now I was searching for a way to do includes like in PHP and other languages. I didn’t found an include function or equal. But I got sth. which does nearly the same:
Dim sScriptPath
' Path to this script
sScriptPath = Left(sScriptPath, Len(WScript.ScriptFullName) - Len(WScript.ScriptName))
' load the file in the path and execute the code
Execute CreateObject("Scripting.FileSystemObject").OpenTextFile(sScriptPath & "file2include.inc").ReadAllI recommend to rename the files from .vbs to .inc or sth. else to prevent manual execution of the files.







