vbscript自定义import函数

vbscript本身不提供impot功能,需要自定义

Sub Import(strFile)
Dim WshShell : Set WshShell = WScript.CreateObject("WScript.Shell")
Dim objFs : Set objFs = CreateObject("Scripting.FileSystemObject")
strFile = WshShell.ExpandEnvironmentStrings(strFile)
strFile = objFs.GetAbsolutePathName(strFile)
Dim objFile : Set objFile = objFs.OpenTextFile(strFile)
strCode = objFile.ReadAll
objFile.Close
ExecuteGlobal strCode
End Sub

 

参考: http://gazeek.com/coding/importing-vbs-files-in-your-vbscript-project/

你可能感兴趣的:(VBScript)