Skip to content

Instantly share code, notes, and snippets.

@h-mochizuki
Created November 25, 2020 04:55
Show Gist options
  • Save h-mochizuki/18d2fe527b18377e5ae54bb6d1972804 to your computer and use it in GitHub Desktop.
Save h-mochizuki/18d2fe527b18377e5ae54bb6d1972804 to your computer and use it in GitHub Desktop.
ダブルクリックすると、バッチのあるフォルダを閉じるバッチ
@if(0)==(0) echo off
setlocal
call cscript //nologo /E:JScript "%~f0" %CD:\=/%
exit /b
@end
var folder = "file:///" + WScript.Arguments(0);
var shellWindows = (new ActiveXObject("Shell.Application")).Windows();
if (shellWindows != null) {
for (var win = new Enumerator(shellWindows); !win.atEnd(); win.moveNext()) {
if (folder == win.item().LocationUrl) win.item().Quit();
}
}
@h-mochizuki
Copy link
Author

バッチをクリックした後でエクスプローラが開いていることによる問題(リネームや削除ができない等)を解消するために使用します。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment