Jr?me,
Do you mean you are writing a .vbs file and want to include external
functions/procedures as executable code?
This can be done two ways.
(1) Use a WSF.
WSF files are discussed in the documentation; they are basically any Windows
scripts "wrapped" in XML, but have all sorts of neat extra abilities. You can
get the docs in French here:
http://download.microsoft.com/download/winscript56/install/5.6/w98nt4...
A WSF file can include external files with a simple declaration.
For example, let's say you save a VBScript subroutine in a text file. You can
write a WSF that loads it and then uses the functions.
Example VBScript code in a file:
'c:\tmp\sub.txt
Sub Hello
MsgBox "Hello, World!"
End Sub
The following WSF file would then load that file and can call the Hello
procedure, like this:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- helloworld.wsf -->
<package>
<job>
<script language="VBScript" src="c:\tmp\sub.txt"/>
<script language="VBScript">
<![CDATA[
Hello
]]>
</script>
</job>
</package>
(2) Write an include function that uses ExecuteGlobal.
You can load text from a file using FSO, then execute the included code using
VBScript's native "Execute" or "ExecuteGlobal" commands. Here is a variation on
the above. This is a pure .vbs file that has an "include" subroutine to load
code from the same text file as above, execute it so it is loaded in the script
engine, then call it.
'helloworld.vbs
Include "c:\tmp\sub.txt"
Hello
Sub Include(FilePath)
' Given the path to a file, will execute entire contents
' in global context
Const ForReading = 1, TristateUseDefault = -2, _
DoNotCreateFile = False
With CreateObject("Scripting.FileSystemObject")._
OpenTextFile(FilePath, ForReading, _
False, TristateUseDefault)
ExecuteGlobal .ReadAll: .Close
End With
End Sub
--
Please respond in the newsgroup so everyone may benefit.
http://dev.remotenetworktechnology.com
----------
Subscribe to Microsoft's Security Bulletins:
http://www.microsoft.com/technet/security/bulletin/notify.asp
Quote:
> I decided to write my batchs in VBS.
> Which is the command to include a file in a vbs-script ?
> I try this :
> <!-- #include file="myFile.inc" -->
> Thanks for any help,
> J.Curvale