Appropriate Tool to Build Modular VBS Scripts
I have a vbscript and the intended purpose is to connect to Windows servers and execute various subs that pull back various pieces of information about the server. However, I have different scripts for different uses, although many of the subs are common between them. I can't just have one large script with command line parameters telling what to run, since I need to deploy these various versions to untrusted people who only need to see particular pieces of the code.
Is there a tool I can use such that I can edit each of these modular subroutines individually and then based on some definition, package them into a particular script that include开发者_如何学编程s the necessary pieces?
Frankly I'm not even sure where to begin searching for something like this since I'm very much an amateur programmer and very little familiarity with things like build tools. If anyone can even point me in the direction of a tool that might do the job, I'm very happy to dive in and do all the research.
Thanks.
Don't bring a baseball bat to a basketball game. If you are performing sensitive routines, you should be using compiled code. VBScript is not the right tool for the job.
That being said, you could consider encrypting your scripts.
Finally, if you really feel you should go the include route, you can read my article over at ASP Free.
Using Includes in VBScript
The code looks something like this:
Import "include.vbs"
Sub Import(ByVal strFile)
Set objFs = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
strFile = WshShell.ExpandEnvironmentStrings(strFile)
file = objFs.GetAbsolutePathName(strFile)
Set objFile = objFs.OpenTextFile(strFile)
strCode = objFile.ReadAll
objFile.Close
ExecuteGlobal(strCode)
End Sub
精彩评论