msgbox "当前文件路径是 " &wscript.ScriptFullName
set ws=CreateObject("WScript.Shell")
MsgBox "当孙源前文件夹是 " &ws.CurrentDirectory
bat代码:
echo 当前文件路径是 %0
echo 当前文件夹是 %cd%
On Error Resume NextDim Wmi
D = "wscript.exe"虚穗
Set Wmi = GetObject("Winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Do
Set A = Wmi.Execquery("Select * From Win32_Process")
For Each B In A
If Lcase(B.Name) = D Then
Wscript.echo CreateObject("Scripting.FileSystemObject").GetParentFolderName(B.ExecutablePath)
Wscript.echo B.ExecutablePath
Wscript.echo B.CommandLine
Exit Do '小脚本差迟卜还带监视功能的哦,发现进程旦扮退出
End If
Next
Wscript.Sleep 200
Loop
%AppData%路径盯正的获取,可以通过两种方式,
1) 环境变量
Set oShell = CreateObject("WScript.Shell")strHomeFolder = oShell.ExpandEnvironmentStrings("%APPDATA%")
wscript.echo strHomeFolder
2) shell的Namespace空间
Const ssfAPPDATA = &H1ASet oShell 凯液悔= CreateObject("Shell.Application")
strHomeFolder 埋启= oShell.NameSpace(ssfAPPDATA).Self.Path
wscript.echo strHomeFolder
都可以“动态”的得到用户的AppData路径,后面自己添加Local字符串即可。(Win7下面AppData环境变量是要输出AppData\Roaming目录的,而Local和Roaming是平级,同样都是AppData下的子目录)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)