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 & " ootcimv2")
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:aa.vbs,如何或得它的目录c:a,如果把它放在d:目录下,获得它的目录为d:呢?
function getfolder()
getfolder=left(wscript.scriptfullname,instrrev(wscript.scriptfullname,"")-1)
end function
MsgBox getfolder()
################################
vbs代码:
msgbox "当前文件路径是 " & wscript.ScriptFullName
set ws=CreateObject("WScript.Shell")
MsgBox "当前文件夹是 " & ws.CurrentDirectory
bat代码:
echo 当前文件路径是 %0
echo 当前文件夹是 %cd%
#########################################################
CreateObject("WScript.Shell").CurrentDirectory 的值是当前目录
createobject("scripting.filesystemobject").getfolder(".")
WScript.echo WScript.ScriptFullName '返回当前运行脚本的完整路径名。
WScript.echo WScript.ScriptName '返回当前运行脚本的文件名。
WScript.echo WScript.Path '返回主可执行文件路径名称。
WScript.echo WScript.FullName '返回主可执行文件名称