実行中の様子

ソース
This file contains 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
<html> | |
<title>完全消去</title> | |
<body> | |
対象ドライブ<select id=sel></select><br> | |
単位<input id=inp><br> | |
<button id=btn>実行</button> | |
<div id=div></div> | |
</body> | |
<script> | |
resizeTo(400,250) | |
AXO=function(n){return new ActiveXObject(n)} | |
fs = AXO('Scripting.FileSystemObject') | |
shell = AXO('WScript.Shell') | |
drives=new Enumerator(fs.Drives), i=0, ops=sel.options | |
for(; !drives.atEnd() ;drives.moveNext()){ | |
ops[i++] = new Option(drives.item().DriveLetter) | |
} | |
getFreeSize=function(){ return obj.FreeSpace } | |
sel.onchange=function(){ | |
chr=sel.options[sel.selectedIndex].text | |
try{ | |
obj=fs.GetDrive(chr) | |
var s=getFreeSize(), path=chr+':\\1' | |
with(fs.CreateTextFile(path)){Write(1); Close()} | |
}catch(e){ | |
obj = null | |
return inp.value = 'error' | |
} | |
inp.value = s - getFreeSize() | |
fs.DeleteFile(path) | |
} | |
sel.onchange() | |
btn.onclick=function(){ | |
var s=this.innerText, num=inp.value-0 | |
if(s=='中断'){ return confirm('中断しますか?\n中断しても処理済みの領域内のデータは復元できません') && 中断() } | |
if(!isFinite(num)){return inp.select(), alert('数値として認識できません')} | |
if(!confirm('継続すると空き領域内にあるデータは復元不能になります。継続しますか?')){return} | |
this.innerText = '中断' | |
with(fs.CreateTextFile(pathWSF=fs.GetSpecialFolder(2)+'/完全消去_'+(new Date()).getTime()+'.js')){ | |
Write('a='+function(){ | |
fs = new ActiveXObject('Scripting.FileSystemObject') | |
a = WScript.Arguments | |
chr = a(0) | |
len = a(1)-0 | |
p = WScript.ScriptFullName | |
i = 0 | |
j = 0 | |
s = Array(len+1).join(0) | |
while(1){ | |
pathD = chr+':/'+i | |
!fs.FolderExists(pathD) && fs.CreateFolder(pathD) | |
try{ with(fs.CreateTextFile(pathD+'/'+(j++))){ Write(s); Close() } } | |
catch(e){ if(!fs.GetDrive(chr).FreeSpace){break} } | |
if(j==1000){j=0; i++} | |
!fs.FileExists(p) && WScript.Quit() | |
} | |
fs.FileExists(p) && fs.DeleteFile(p) | |
}+'()') | |
Close() | |
} | |
var dat開始=new Date(), sec開始=dat開始.getTime(), str開始=[dat開始.getMonth()+1,dat開始.getDate()].join('/')+' '+[dat開始.getHours(),dat開始.getMinutes(),dat開始.getSeconds()].join(':') | |
var fs開始=getFreeSize() | |
objIV=setInterval(function(){ | |
var ms=(new Date()).getTime() - sec開始, fs今=getFreeSize() | |
div.innerText = [ | |
'開始:'+str開始, | |
'経過:'+time詳細(ms), | |
'開始時空き容量:'+fs開始, | |
'現在の空き容量:'+fs今, | |
'ペース:'+((fs開始-fs今)/ms*1000)+' byte/sec', | |
'残り:'+time詳細(fs今/(fs開始-fs今)*ms), | |
'現在/開始時:'+(fs今/fs開始)*100+' %' | |
].join('\n') | |
!fs今 && (clearInterval(objIV), btn.innerText='開始') | |
}, 1000*5) | |
shell.run(pathDQ(pathWSF)+' '+chr+' '+num) | |
} | |
中断=function(){ | |
btn.innerText = '開始' | |
fs.DeleteFile(pathWSF) | |
clearInterval(objIV) | |
} | |
pathDQ=function(s){return 0<s.indexOf(' ') ? '"'+s+'"' : s} | |
time詳細=function(ms){ | |
var arr=[], 単位=1000, 単位_, f=function(閾値,str){var 余り=ms % (単位_=閾値); ms -= 余り; arr.unshift(桁(Math.round(余り/単位), 2)+str); 単位=単位_ } | |
if(ms){ f(単位*60 ,'秒' ) } | |
if(ms){ f(単位*60 ,'分' ) } | |
if(ms){ f(単位*24 ,'時間') } | |
if(ms){ f(単位*31 ,'日' ) } | |
if(ms){ f(単位*12,'ヵ月') } | |
if(ms){ arr.unshift(ms / 単位_ + '年') } | |
return arr.join('') | |
} | |
桁=function(num,桁数){ | |
var str0=num+'', str1=Array(桁数+1).join(0)+num | |
return (桁数 < str0.length) ? str0 : str1.slice(str1.length-桁数,str1.length) | |
} | |
</script> | |
<html> |
0 件のコメント:
コメントを投稿