Created
June 17, 2010 07:58
-
-
Save 0mg/441824 to your computer and use it in GitHub Desktop.
Secure Delete SendToTarget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // Secure Delete SendToTarget | |
| // | |
| if (WScript.arguments.length > 0) { | |
| var wsh = WScript.createObject("WScript.Shell"); | |
| var fso = WScript.createObject("Scripting.FileSystemObject"); | |
| // | |
| // 引数を配列にする | |
| // | |
| for (var wsh_args = [], i = 0; i < WScript.arguments.length; ++i) { | |
| wsh_args.push(WScript.arguments.item(i)); | |
| } | |
| wsh_args = optArgs(wsh_args); | |
| // | |
| // 配列の重複をなくす | |
| // | |
| function optArgs(args) { | |
| for (var opted_args = [], i = 0; i < args.length; ++i){ | |
| for (var j = i + 1; j < args.length; ++j) { | |
| if (args[i] === args[j]) break; | |
| } | |
| if (args.length === j) opted_args.push(args[i]); | |
| } | |
| return opted_args; | |
| }; | |
| // | |
| // 引数が実際に存在するファイル/フォルダ名なら配列に格納する | |
| // | |
| var files = []; | |
| for (var i = 0; i < wsh_args.length; ++i) { | |
| if (fso.fileExists(wsh_args[i])) { | |
| files.push(fso.getFile(wsh_args[i])); | |
| } else if (fso.folderExists(wsh_args[i])) { | |
| files.push(fso.getFolder(wsh_args[i])); | |
| } else { | |
| WScript.echo((wsh_args[i]) + | |
| " はファイルではないか、もう存在しません"); | |
| } | |
| } | |
| // | |
| // ファイル/フォルダを削除する | |
| // | |
| if (files.length) { | |
| files = optArgs(files); // "hoge.bak" と ".\hoge.bak" などの重複を整理 | |
| if (wsh.popup(files.length + " 個のアイテムを抹消しますか?\n\n" + | |
| files.join("\n"), 0, "Secure Delete", 3 + 48) === 6) { | |
| for (var i = 0; i < files.length; ++i) { | |
| wsh.run('sdelete -s "' + files[i].path + '"', 0); | |
| } | |
| } | |
| } | |
| } else WScript.echo("ファイル名を引数として渡して下さい"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment