您好我看到了这个问题How can I get the current active window at the time a batch script is run?
但并没有得到我想要的东西。他们给出了jscript和powershell脚本的答案...所以我们不能使用dos命令在屏幕上打开活动窗口的路径。
请帮忙。
已经尝试过 - %cd%::但是它给出了批处理文件所在的路径,而不是当前在桌面上打开和激活的文件夹
答案 0 :(得分:0)
Set Arg = WScript.Arguments
set WshShell = createObject("Wscript.Shell")
Set Inp = WScript.Stdin
Set Outp = Wscript.Stdout
Set objShell = CreateObject("Shell.Application")
Set AllWindows = objShell.Windows
For Each window in AllWindows
outp.writeline window.locationname
Next
使用
cscript /nologo c:\pathtoscript\script.vbs
请注意,出于历史原因,它会执行Explorer和Internet Explorer窗口 - 它们曾经是同一个程序。
这给出了像这样的输出
Microsoft Windows [Version 6.0.6002]
Copyright (c) 2006 Microsoft Corporation. All rights reserved.
C:\Users\David Candy>cscript /nologo "C:\Users\David Candy\Documents\Assorted\Sc
ripts\ListOpenShellWindowsStdOut.vbs"
Newest 'batch-file' Questions - Stack Overflow
dos command or batch file to get the path for the current active folder opened o
n my screen - Stack Overflow
Music
Favorites
要进入批处理变量,请使用for循环
for /f "delims=" %%A in ('cscript // nologo script.vbs') do Echo %%A