Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do I include a *.INC file in a *.VBS file ?

381 views
Skip to first unread message

Oskar H.

unread,
Apr 24, 2001, 5:03:02 PM4/24/01
to
Hi there.
How do I include a *.INC file in a *.VBS file ?
I am using *.vbs files at my server to perform various tasks and run them
either from a command prompt or by a scheduler.
In *.ASP files I can use the following syntax <!--#include
file="somefile.inc"--> and in the old QBacic I could use the #INCLUDE
"somefile.inc" but there seem to be no way getting this to work for *.vbs
files.
Is there realy no way reusing functions and subroutines in vbs files ?

Best regards
Oskar H.

Oskar H.

unread,
Apr 24, 2001, 5:44:47 PM4/24/01
to
Hello again.
I happend to find a solution to this problem by searching for VBS INCLUDE
on the http://groups.google.com and I found the sample code from Michael
Harris (Microsoft.MVP.Scripting) most use full (see below).
There happens to be two solution to this problem.
Regards
Oskar H.
-------
Michael Harris wrote :

You can use FSO to read a vbscript file as text and use ExecuteGlobal on the
text to add it to the
current script's namespace exactly as if it had been coded at that point in
the script to start
with.

Include "somecode.vbs"

Sub Include(sCodeFile)
Dim sCode
with createobject("scripting.filesystemobject")
sCode = .OpenTextFile(sCodeFile).ReadAll
End With
ExecuteGlobal sCode
End Sub

Or you can use .wsf files instead of just .vbs files

<job>
<script language="vbscript" src="somecode.vbs" />
<script language="vbscript">
...
...mainline vbscript here...
result = CommonFunction(arg)
...
</script>
</job>

"Oskar H." <osk...@centrum.is> wrote in message
news:umGKTCQzAHA.2100@tkmsftngp05...

0 new messages