CMD當(dāng)前路徑
代碼如下:
test = createobject("Scripting.FileSystemObject").GetFolder(".").Path
Wscript.echo test
當(dāng)前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
如何獲得當(dāng)前.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()
更多信息請查看IT技術(shù)專欄