在一个vbs中包含其他vbs文件的方法
(编辑:jimmy 日期: 2024/11/15 浏览:3 次 )
asp中 include file 包含其他文件
vbs中
复制代码 代码如下:
Option Explicit
On Error Resume Next
Sub include(vbs)
Dim fso : Set fso = CreateObject("scripting.FileSystemObject")
Dim p : p = Split(Wscript.ScriptFullName,"\")
p(UBound(p)) = vbs
p = Join(p,"\")
Dim f : Set f = fso.OpenTextFile(p)
Execute f.ReadAll()
' ExecuteGlobal f.ReadAll()
f.Close()
Set f = Nothing
Set fso = Nothing
' Wscript.Echo(p)
End Sub
include("1.vbs")
include("2.vbs")
'If Err Then
' Wscript.Echo(Err.description)
' Wscript.Quit()
'End If
Wscript.Echo(a+b)
1.vbs
a = 3
2.vbs
b = 4
vbs中
复制代码 代码如下:
Option Explicit
On Error Resume Next
Sub include(vbs)
Dim fso : Set fso = CreateObject("scripting.FileSystemObject")
Dim p : p = Split(Wscript.ScriptFullName,"\")
p(UBound(p)) = vbs
p = Join(p,"\")
Dim f : Set f = fso.OpenTextFile(p)
Execute f.ReadAll()
' ExecuteGlobal f.ReadAll()
f.Close()
Set f = Nothing
Set fso = Nothing
' Wscript.Echo(p)
End Sub
include("1.vbs")
include("2.vbs")
'If Err Then
' Wscript.Echo(Err.description)
' Wscript.Quit()
'End If
Wscript.Echo(a+b)
1.vbs
a = 3
2.vbs
b = 4
下一篇:雷客图ASP站长安全助手vbs测试版代码