-1

I have a VBScript file, in which my functions are defined. In my other VBScripts i include this file, and so i can use the defined functions. My Problem is, that this way, anyone can see my predefined functions. Is it possible somehow to make a lib or some other file from my VBScript file, which i can include in my later VBScripts, and use it's functions?

Thanks!

kampi
  • 2,362
  • 12
  • 52
  • 91
  • possible duplicate of [VBscript compiler](http://stackoverflow.com/questions/1434079/vbscript-compiler) – sloth Sep 12 '13 at 08:25

2 Answers2

2

VBScript doesn't have an import concept, so what you want isn't really supported in plain VBScript. There is a workaround, though, utilizing the ExecuteGlobal statement:

Set fso = CreateObject("Scripting.FileSystemObject")
code = fso.OpenTextFile("C:\path\to\library.vbs").ReadAll
ExecuteGlobal code

You can also import other script files in WSF scripts (see this sample chapter from VBScript in a Nutshell, section "Reusable Code Libraries"):

<PACKAGE>
<JOB ID=Sample>
<SCRIPT LANGUAGE="VBScript" SRC="C:\path\to\library.vbs" />
<SCRIPT>
result = FunctionFromLibrary("arg1", "arg2")
</SCRIPT>
</JOB>
</PACKAGE>
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
1

You can try Window Script Components.

This basically allows you to wrap up your VBScript code as a COM object, making it accessible via CreateObject().

Your code is still stored in plain text, however.

  • Hi! Thanks, but the reason why i want to make a lib is that, that my code should not be in plain text :) – kampi Sep 12 '13 at 10:19