欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

vbs获取当前路径的代码

程序员文章站 2022-04-24 09:16:58
...
CMD当前路径
test = createobject("Scripting.FileSystemObject").GetFolder(".").Path
Wscript.echo test

当前VBS路径

test = createobject("Scripting.FileSystemObject").GetFile(Wscript.ScriptFullName).ParentFolder.Path
Wscript.echo test
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") 
Set colItems = objWMIService.ExecQuery("Select * From Win32_Process Where Name = 'wscript.exe' OR Name = 'cscript.exe'")
For Each objItem in colItems
lmq=lmq & objItem.CommandLine & vbcrlf
Next
Wscript.Echo lmq

如何获得当前.vbs文件运行的目录
比方说c:\a\a.vbs,如何或得它的目录c:\a,如果把它放在d:\b\b\目录下,获得它的目录为d:\b\b呢?

function getfolder() 
getfolder=left(wscript.scriptfullname,instrrev(wscript.scriptfullname,"\")-1) 
end function 
MsgBox getfolder()

更多vbs获取当前路径的代码相关文章请关注PHP中文网!

相关标签: vbs获取当前路径