CMD當(dāng)前路徑
代碼如下:
test=createobject("Scripting.FileSystemObject").GetFolder(".").Path
Wscript.echotest
當(dāng)前VBS路徑
代碼如下:
test=createobject("Scripting.FileSystemObject").GetFile(Wscript.ScriptFullName).ParentFolder.Path
Wscript.echotest
代碼如下:
strComputer="."
SetobjWMIService=GetObject("winmgmts:\\"&strComputer&"\root\cimv2")
SetcolItems=objWMIService.ExecQuery("Select*FromWin32_ProcessWhereName='wscript.exe'ORName='cscript.exe'")
ForEachobjItemincolItems
lmq=lmq&objItem.CommandLine&vbcrlf
Next
Wscript.Echolmq
如何獲得當(dāng)前.vbs文件運行的目錄
比方說c:\a\a.vbs,如何或得它的目錄c:\a,如果把它放在d:\b\b\目錄下,獲得它的目錄為d:\b\b呢?
代碼如下:
functiongetfolder()
getfolder=left(wscript.scriptfullname,instrrev(wscript.scriptfullname,"\")-1)
endfunction
MsgBoxgetfolder()
更多信息請查看IT技術(shù)專欄