圆月山庄资源网 Design By www.vgjia.com
复制代码 代码如下:
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" )

WScript.Echo "Script:"
WScript.Echo "ScriptFullName:", WScript.ScriptFullName
WScript.Echo "ScriptFullPath:", oFS.GetParentFolderName( WScript.ScriptFullName )
WScript.Echo "Current:"
WScript.Echo "FS:", oFS.GetAbsolutePathName( ".\" )
WScript.Echo "WS:", oWS.CurrentDirectory

-------- output -------------

C:\wis\_vbs\0506\dev\forum
cscript curdir.vbs
Script:
ScriptFullName: C:\wis\_vbs\0506\dev\forum\curdir.vbs
ScriptFullPath: C:\wis\_vbs\0506\dev\forum
Current:
FS: C:\wis\_vbs\0506\dev\forum
WS: C:\wis\_vbs\0506\dev\forum

C:\wis\_vbs\0506\dev\forum
cd ..

C:\wis\_vbs\0506\dev
cscript forum\curdir.vbs
Script:
ScriptFullName: C:\wis\_vbs\0506\dev\forum\curdir.vbs
ScriptFullPath: C:\wis\_vbs\0506\dev\forum
Current:
FS: C:\wis\_vbs\0506\dev
WS: C:\wis\_vbs\0506\dev

参考资料:http://www.visualbasicscript.com/m43018.aspx
标签:
同一目录,可执行程序

圆月山庄资源网 Design By www.vgjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
圆月山庄资源网 Design By www.vgjia.com