回复 7# yunyan100
如你所说,自由决定关闭文件夹路径,遍历其下打开的所有文件夹,找到符合条件的窗口就关闭它。WIN10测试通过。- @if (0)==(0) echo off
- set /p "strFolder=拖入遍历的文件夹 : "
- for /f "tokens=*" %%i in ('dir /s/b/ad %strFolder%') do (
- cscript -nologo -e:jscript %~s0 CloseOpenWindow "%%~ni"
- echo,
- )
- pause
- goto :EOF
- @end
-
- var func = WScript.Arguments(0);
- var str = WScript.Arguments(1);
-
- switch (func) {
- case "CloseOpenWindow":
- CloseOpenWindow(str);
- break;
- default:;
- }
-
- function CloseOpenWindow(str) {
- WScript.Echo("当前传入参数为 : " + str);
- var oShell = new ActiveXObject("WScript.Shell");
- var ret = oShell.AppActivate(str);
- WScript.Echo("打开状态 : " + ret);
- if (ret) {
- /// 打开状态为真时,关闭它
- oShell.SendKeys("%{F4}");
- WScript.Echo("存在打开文件夹 " + str + " ,关闭之");
- }
- }
复制代码
|