Set objShell = CreateObject("WScript.shell") strCurrentDir = objShell.CurrentDirectory set fso = createobject("scripting.filesystemobject") set f=fso.getfolder(strCurrentDir) For Each i In f.files If LCase(right(i,4)) = ".exe" Then objShell.Run i,,true Next
获取脚本所在目录还可以:
复制代码 代码如下:
set fso = createobject("scripting.filesystemobject") fso.GetParentFolderName(WScript.ScriptFullName)
一时想不到更好的办法判断文件是不是.exe了…… 就这样了。
复制代码 代码如下:
Option Explicit
Dim oFS : Set oFS = CreateObject( "Scripting.FileSystemObject" ) Dim oWS : Set oWS = CreateObject( "WScript.Shell" )