If MsgBox("今から、" & sRootDir & "以下のフォルダ内にある全idxファイルを検索し、" & vbCrLf & _ "書き込みしたスレの最終書き込み日時データを消去します。いいですか?",vbYesNo)=vbNo Then WScript.Quit End If
iNewSure=0 iKakikoSure=0
If Fs.FileExists(sIniFile) Then Set ts=Fs.OpenTextFile(sIniFile) If Not ts.AtEndOfStream Then sLastTime=ts.ReadLine ts.Close dLastTime=CDate(sLastTime) Else dLastTime=CDate("1970/01/01 00:00:00") End If
Set ts=Fs.CreateTextFile(sIniFile,True) ts.Write Now '現在の日時を設定ファイルに書き込む ts.Close
If Fs.FileExists(sKakikomi) Then If MsgBox("kakikomi.txtを削除しますか?",vbYesNo)=vbYes Then Fs.DeleteFile sKakikomi 'kakikomi.txt削除 sMsg=sMsg & vbCrLf & "kakikomi.txtを削除しました。" End If End If
MsgBox sMsg
Sub CheckDir(Folder) For Each oFile In Folder.Files If LCase(Fs.GetExtensionName(oFile.Name))="idx" Then If DateDiff("s",oFile.DateLastAccessed,dLastTime) < 0 Then iNewSure=iNewSure + 1 Set ts=Fs.OpenTextFile(oFile.Path) If Not ts.AtEndOfStream Then sLine=ts.ReadLine ts.Close aCell=Split(sLine,vbTab) If UBound(aCell) >=11 Then If aCell(11)<>"" Then iKakikoSure=iKakikoSure + 1 aCell(11)="" Set ts=Fs.CreateTextFile(oFile.Path,True) ts.Write Join(aCell,vbTab) '最終取得日時を消したものを上書き ts.Close End If End If End If End If Next For Each oSubFolder In Folder.SubFolders Call CheckDir(oSubFolder) Next End Sub
>>454 [1] If MsgBox("今から、" & sRootDir & "以下のフォルダ内にある全idxファイルを検索し、" & vbCrLf & _ "書き込みしたスレの最終書き込み日時データを消去します。いいですか?",vbYesNo)=vbNo Then WScript.Quit End If →削除
[2] If Fs.FileExists(sKakikomi) Then If MsgBox("kakikomi.txtを削除しますか?",vbYesNo)=vbYes Then Fs.DeleteFile sKakikomi 'kakikomi.txt削除 sMsg=sMsg & vbCrLf & "kakikomi.txtを削除しました。" End If End If
↓このように修正
If Fs.FileExists(sKakikomi) Then Fs.DeleteFile sKakikomi 'kakikomi.txt削除 End If
Set WshShell = WScript.CreateObject("WScript.Shell") Set Fs = WScript.CreateObject("Scripting.FileSystemObject") iDel=0 : iLeft=0 For Each sArg In WScript.Arguments If Fs.FolderExists(sArg) Then For Each oFol In Fs.GetFolder(sArg).SubFolders 'add If oFol.Files.Count<=2 And oFol.SubFolders.Count=0 Then If Fs.FileExists(sArg & "\"& oFol.name & "\" & "Desktop.ini") Then Fs.DeleteFile(sArg & "\"& oFol.name & "\" & "Desktop.ini") 'msgbox("あぼーんDesktop.ini") End If If Fs.FileExists(sArg & "\"& oFol.name & "\" & "サムネイル.db") Then Fs.DeleteFile(sArg & "\"& oFol.name & "\" & "サムネイル.db") 'msgbox("あぼーんサムネイル.db") End If End If 'end
If oFol.Files.Count=0 And oFol.SubFolders.Count=0 Then iDel=iDel+1 oFol.Delete Else iLeft=iLeft+1 End If Next End If Next MsgBox iDel & "個の空フォルダを削除しました。" & vbCrLf & iLeft & "個のフォルダは空ではないです。"
Set WshShell = WScript.CreateObject("WScript.Shell") Set Fs = WScript.CreateObject("Scripting.FileSystemObject") iDel=0 : iLeft=0 Dim cnt'変数追加 For Each sArg In WScript.Arguments If Fs.FolderExists(sArg) Then For Each oFol In Fs.GetFolder(sArg).SubFolders '追加始まり If Fs.FileExists(sArg & "\"& oFol.name & "\" & "Desktop.ini") Then cnt=cnt+1 End If If Fs.FileExists(sArg & "\"& oFol.name & "\" & "サムネイル.db") Then cnt=cnt+1 End If If oFol.Files.Count=cnt And oFol.SubFolders.Count=0 Then If Fs.FileExists(sArg & "\"& oFol.name & "\" & "Desktop.ini") Then Fs.DeleteFile(sArg & "\"& oFol.name & "\" & "Desktop.ini") End If If Fs.FileExists(sArg & "\"& oFol.name & "\" & "サムネイル.db") Then Fs.DeleteFile(sArg & "\"& oFol.name & "\" & "サムネイル.db") End If End If cnt=0 '追加終わり
If oFol.Files.Count=0 And oFol.SubFolders.Count=0 Then iDel=iDel+1 oFol.Delete Else iLeft=iLeft+1 End If Next End If Next MsgBox iDel & "個の空フォルダを削除しました。" & vbCrLf & iLeft & "個のフォルダは空ではないです。"
Set WshShell = WScript.CreateObject("WScript.Shell") Set Fs = WScript.CreateObject("Scripting.FileSystemObject") Dim SumSize Dim m For Each sArg In WScript.Arguments If Fs.FolderExists(sArg) Then SumSize=0 For Each oFol In Fs.GetFolder(sArg).SubFolders m=m & oFol & chr(9) & CStr(oFol.size) & chr(13) Next End If Next msgbox m フォルダサイズを調べるスクリプト
Set WshShell = WScript.CreateObject("WScript.Shell") Set Fs = WScript.CreateObject("Scripting.FileSystemObject") Dim m For Each sArg In WScript.Arguments If Fs.FolderExists(sArg) Then For Each oFol In Fs.GetFolder(sArg).SubFolders m=m & oFol & chr(9) & CStr(CLng(oFol.size/1024)) & chr(13) Next End If Next msgbox m kb表示
If iButton= -1 Or iButton = vbOK Then Set oSystemSet=GetObject ("winmgmts:{impersonationLevel=impersonate,(Shutdown)}") _ .InstancesOf("Win32_OperatingSystem") For Each oSystem In oSystemSet oSystem.Win32Shutdown 0 '0 ログオフ '1 シャットダウン(電源は切れない) '2 再起動 '4 強制終了? '8 電源オフ Next End If
Function FormatTime(sec) h=0 : m=0 : s = sec :ret="" If s >= 3600 Then h = s \ 3600 s = s mod 3600 ret = ret & h & "時間" End If If s >= 60 Then m = s \ 60 s = s mod 60 ret = ret & m & "分" End If If s > 0 Then ret = ret & s & "秒" End If FormatTime = ret End Function
Set WshShell = WScript.CreateObject("WScript.Shell") Set Fs = WScript.CreateObject("Scripting.FileSystemObject") iDel = 0 For Each sArg In WScript.Arguments If Fs.FolderExists(sArg) Then Set Fld = Fs.GetFolder(sArg) iDel = iDel + DelFld(Fld) End if Next status = WshShell.Popup(iDel & "個のフォルダを削除しました。", 2, "空フォルダの削除")
Function DelFld(Fld) subiDel = 0 For Each oFol in Fld.SubFolders subiDel = subiDel + DelFld(oFol) Next If Fld.Files.Count = 0 And Fld.SubFolders.Count = 0 Then Fld.Delete subiDel = subiDel + 1 End If DelFld = subiDel End Function
Set WshShell = WScript.CreateObject("WScript.Shell") Set Fs = WScript.CreateObject("Scripting.FileSystemObject") iDel=0 : iLeft=0 Dim cnt'変数追加 For Each sArg In WScript.Arguments If Fs.FolderExists(sArg) Then For Each oFol In Fs.GetFolder(sArg).SubFolders '追加始まり If Fs.FileExists(sArg & "\"& oFol.name & "\" & "desktop.ini") Then cnt=cnt+1 End If If Fs.FileExists(sArg & "\"& oFol.name & "\" & "Thumbs.db") Then cnt=cnt+1 End If If oFol.Files.Count=cnt And oFol.SubFolders.Count=0 Then If Fs.FileExists(sArg & "\"& oFol.name & "\" & "desktop.ini") Then Fs.DeleteFile(sArg & "\"& oFol.name & "\" & "desktop.ini") End If If Fs.FileExists(sArg & "\"& oFol.name & "\" & "Thumbs.db") Then Fs.DeleteFile(sArg & "\"& oFol.name & "\" & "Thumbs.db") End If End If cnt=0 '追加終わり
If oFol.Files.Count=0 And oFol.SubFolders.Count=0 Then iDel=iDel+1 oFol.Delete Else iLeft=iLeft+1 End If Next End If Next MsgBox iDel & "個の空フォルダを削除しました。" & vbCrLf & iLeft & "個のフォルダは空ではないです。"
For Each sArg In WScript.Arguments '引数として指定したフォルダを処理対象にする。 If Fs.FolderExists(sArg) Then Call MakeList(Fs.GetFolder(sArg)) End If Next
を
For Each sArg In WScript.Arguments If Fs.FolderExists(sArg) Then sListFile=Fs.BuildPath(sArg,"list.m3u" ) Call MakeList(Fs.GetFolder(sArg)) End If Next
Dim RegEx,RegEx2,Fs Set Fs = WScript.CreateObject("Scripting.FileSystemObject") Set RegEx=New RegExp Set RegEx2=New RegExp RegEx.IgnoreCase=True RegEx.Global=True
For Each sArg In WScript.Arguments If Fs.FolderExists(sArg) Then For Each oFile In Fs.GetFolder(sArg).Files Call RenameHTMLFile(oFile) Next ElseIf Fs.FileExists(sArg) Then Call RenameHTMLFile(Fs.GetFile(sArg)) End If Next
Sub RenameHTMLFile(File) ext=LCase(Fs.GetExtensionName(File.Name)) If ext="htm" Or ext="html" Then Set ts=Fs.OpenTextFile(File.Path) sDoc=ts.ReadAll RegEx.Pattern="<\s*title\s*>\s*((?:.|\n)*)\s*<\s*\/title\s*>" Set Matches=RegEx.Execute(sDoc) For Each Match In Matches RegEx.Pattern="(?:[\\\/\:\,\;\*\?\""<>\|\t]|\r\n|\r|\n)" sTitle=RegEx.Replace(Match.SubMatches(0),"_") Next ts.Close If sTitle<>"" Then sNewName=sTitle & "." & ext sNewPath=Fs.BuildPath(Fs.GetParentFolderName(File.Path),sNewName) Do While Fs.FileExists(sNewPath) RegEx.Pattern="(.*)\[(\d+)\]$" If RegEx.Test(sTitle) Then sNumber=RegEx.Execute(sTitle)(0).SubMatches(1) If IsNumeric(sNumber) Then sTitle = RegEx.Replace(sTitle,"$1" & "[" & CInt(sNumber) + 1 & "]") Else sTitle = RegEx.Replace(sTitle,"$1" & "[0]") End If Else sTitle=sTitle & "[0]" End If sNewName=sTitle & "." & ext sNewPath=Fs.BuildPath(Fs.GetParentFolderName(File.Path),sNewName) Loop File.Name = sNewName End If End If End Sub
>>506 Dim ts,sList Set Fs = WScript.CreateObject("Scripting.FileSystemObject") Randomize
For Each sArg In WScript.Arguments If Fs.FolderExists(sArg) Then sList="" Call MakeList(Fs.GetFolder(sArg)) aList=Split(sList,vbCrLf) For I=0 To UBound(aList) n=Int(Rnd()*UBound(aList)) m=Int(Rnd()*UBound(aList)) tmp=aList(n) aList(n)=aList(m) aList(m)=tmp Next sList=Join(aList,vbCrLf) Set ts=Fs.CreateTextFile(Fs.BuildPath(sArg,"list.m3u")) ts.Write sList ts.Close End If Next MsgBox "終了"
Dim WshShell, oExec, regEx Set WshShell = CreateObject("WScript.Shell") Set regEx = New RegExp
For i = 150 To 190 Set oExec = WshShell.Exec("ping -n 1 61.116.87." & i) Do While oExec.Status <> 1: WScript.Sleep 100: Loop res = oExec.StdOut.ReadAll regEx.Pattern = "Reply .* time.*" regEx.IgnoreCase = True Set Matches = regEx.Execute(res)
If Matches.Count > 0 Then WScript.Echo Matches(0).Value End If Next
Set SHELL = WScript.CreateObject("Shell.Application") For Each DESKTOPFOLDER In SHELL.NameSpace(0).Items If DESKTOPFOLDER.Name = "ごみ箱" Then DESKTOPFOLDER.InvokeVerb "ごみ箱を空にする(&B)" WScript.Quit 0 End If Next
function cleenUpTempFile(folderPath) { var targetFolder = fso.GetFolder(folderPath); for (var en = new Enumerator(targetFolder.Files); !en.atEnd(); en.moveNext()) { var ext = fso.GetExtensionName(en.item().Path); if (ext != "exe" && ext != "dll") en.item().Delete(); } }
>>525 Dim ts,sList Set Fs = WScript.CreateObject("Scripting.FileSystemObject") Randomize For Each sArg In WScript.Arguments If Fs.FolderExists(sArg) Then Call MakeList(Fs.GetFolder(sArg)) aList=Split(sList,vbCrLf) For I=0 To UBound(aList) n=Int(Rnd()*UBound(aList)) m=Int(Rnd()*UBound(aList)) tmp=aList(n) aList(n)=aList(m) aList(m)=tmp Next sList=Join(aList,vbCrLf) sParent=Fs.GetParentFolderName(sArg) End If Next Set ts=Fs.CreateTextFile(Fs.BuildPath(sParent,"list.m3u")) ts.Write sList ts.Close MsgBox "終了" と Sub MakeList(Folder)以下追加。これでどうだ。 というか、このスクリプト、何回改造されれば気がすむんだか(w
参考例。 '30日以内に更新されたファイルを選択 Set Shell = WScript.CreateObject("Shell.Application") For Each window In Shell.Windows Set document=window.document If typename(document)="IShellFolderViewDual" Then Set oFolder = document.Folder Set oFolderItems = oFolder.Items For Each oFolderItem In oFolderItems If DateDiff("d",oFolderItem.ModifyDate,Now)<=30 Then document.SelectItem oFolderItem,1 '選択 Else document.SelectItem oFolderItem,0 '選択解除 End If Next window.StatusText="30日以内に更新された" & _ document.SelectedItems.Count & "個のオブジェクトを選択" End If Next
Sub MoveFilesToRecycleBin(Folder,Files) Set Ie = WScript.CreateObject("InternetExplorer.Application") Ie.Navigate Folder Do While Ie.Busy Or Ie.ReadyState<>4 WScript.Sleep 10 Loop Set document=Ie.Document Set oFolder = document.Folder Set oFolderItems = oFolder.Items For Each oFolderItem In oFolderItems For Each sFileName In Files If LCase(oFolderItem.Name) = LCase(sFileName) Then document.SelectItem oFolderItem,1 Exit For Else document.SelectItem oFolderItem,0 End If Next Next document.SelectedItems.InvokeVerbEx "delete" Ie.Quit End Sub
参考例その3 '表示中のフォルダのHTMLソース表示。 Set oShell = CreateObject("Shell.Application") For Each oWindow In oShell.Windows Set oDocument=oWindow.document If TypeName(oDocument)="HTMLDocument" Then msgbox oDocument.body.parentElement.outerHTML,,oWindow.LocationURL ElseIf TypeName(oDocument)="IShellFolderViewDual" Or _ TypeName(oDocument)="WebViewFolderContents" Then msgbox oDocument.Script.document.body.parentElement.outerHTML,, _ oDocument.Folder.Items.Item.Path End If Next
参考例その4 'misc。何が起こるかはコメント行参照。 On Error Resume Next Set Shell = WScript.CreateObject("Shell.Application") For Each window In Shell.Windows Set document=window.document If typename(document)="IShellFolderViewDual" Then Set oScript = document.Script 'HTMLWindow2オブジェクトを返す If document.Folder.title="ごみ箱" Then msg=msgbox (oScript.L_Intro_Text & vbCrLf & "ゴミ箱を空にしますか?", _ vbYesNo) '変数の表示 If msg=vbYes Then Call oScript.Empty '関数の実行 Else msgbox oScript.Info.InnerText '情報ペインに表示されている内容を表示 oScript.FolderName.InnerText="WSHからのいたずら" 'フォルダ名を書き換える oScript.window.document.body.style.color="red" '文字を赤に(スタイルの変更) End If End If Next
<html><script language="JavaScript"> var uri = new String(external.menuArguments.event.srcElement.href); var adTypeBinary = 1; var adSaveCreateNotExist = 1; var adSaveCreateOverWrite = 2; var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); var Stream = new ActiveXObject("Adodb.Stream"); var WshShell = new ActiveXObject("WScript.Shell"); xmlhttp.Open("GET", uri, false); xmlhttp.Send() Stream.Type = adTypeBinary; Stream.Open(); Stream.Write(xmlhttp.responseBody); Stream.SaveToFile("$tempsrc.txt", adSaveCreateOverWrite); WshShell.Run ("$tempsrc.txt"); </script></html>
たとえば、起動中のメモ帳をすべて終了させるなら、以下のようにする。 For each Process in GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_Process where Name='notepad.exe'") Process.Terminate Next
dim d,e:d=0:e=0 title="empty folder search" set a=createobject("scripting.filesystemobject") call search(a.getfolder("C:\")) msgbox "Search was finished."&vbcr&"There were "&d&" folders in your drive."&vbcr& _ "And "&e&" folder was (or folders were) removed.",4096+vbinformation,title
sub search(t) for each b in t.subfolders d=d+1 if b.subfolders.count<>0 then call search(b) if b.subfolders.count=0 and _ (-a.fileexists(b.path&"\desktop.ini")-a.fileexists(b.path&"\thumbs.db")=b.files.count or b.size=0) then 'if b.subfolders.count=0 and b.files.count=0 then c=msgbox(b.path&vbcr&"is empty."&vbcr&"Do you want to remove this folder?",4096+vbyesnocancel,title) if c=vbyes then b.delete(true) e=e+1 elseif c=vbcancel then wscript.quit end if end if next end sub
>>559 眠いけどれすれす。 Set newwindow=window.open("hogehoge") Set newwindow.document.body.onload=GetRef("newwindow_onload") Set newwindow.document.body.onunload=GetRef("newwindow_onunload")
Sub newwindow_onload() 'ウィンドウロード時の処理 End Sub てな感じ。
DIM D,E,LIST() D=0:E=0 TITLE="empty folder search" SET A=CREATEOBJECT("SCRIPTING.FILESYSTEMOBJECT") FOR EACH Q IN CREATEOBJECT("WSCRIPT.SHELL").SPECIALFOLDERS REDIM PRESERVE LIST(N) LIST(N)=Q N=N+1 NEXT FOR EACH ARG IN WSCRIPT.ARGUMENTS IF A.FOLDEREXISTS(ARG) THEN CALL SEARCH(A.GETFOLDER(ARG),FALSE) ARGS=ARGS&ARG&VBCR END IF NEXT IF ARGS="" THEN ARGS=LEFT(WSCLIPT.SCRIPTFULLNAME,3) CALL SEARCH(A.GETFOLDER(ARGS),TRUE) ARGS=ARGS&VBCR END IF MSGBOX ARGS&"総フォルダ数: "&D&VBCR&"削除したフォルダ数: "&E,4160,TITLE
SUB SEARCH(T,MSG) FOR EACH B IN T.SUBFOLDERS D=D+1 IF B.SUBFOLDER.COUNT<>0 THEN CALL SEARCH(B,MSG) IF B.SUBFOLDER.COUNT=0 THEN PATH=B.PATH IF -A.FILEEXISTS(PATH&"\desktop.ini")-A.FILEEXISTS(PATH&"\tumbs.db")=B.FILE.COUNT OR B.SIZE=0 THEN IF ISNOTSPECIALFOLDER(PATH) THEN IF MSG THEN C=MSGBOX(PATH&VBCR&"は空です。削除しますか?",4099,TITLE) IF C=VBYES THEN B.DELETE(TRUE) E=E+1 ELSEIF C=VBCANCEL THEN WSCRIPT.QUIT END IF ELSE B.DELETE(TRUE) E=E+1 END IF END IF END IF END IF NEXT END SUB
FUNCTION ISNOTSPECIALFOLDER(P) FOR EACH Q IN LIST IF Q=P THEN EXIT FUNCTION NEXT ISNOTSPECIALFOLDER=TRUE END FUNCTION
Set ts=Fs.CreateTextFile(sListFile) Call MakeList(Fs.GetFolder(sFolder)) ts.Close
SET WSHShell = WScript.CreateObject("WScript.Shell") WSHShell.Run sListFile
Sub MakeList(Folder) For Each oFile In Folder.Files sExt=LCase(Fs.GetExtensionName(oFile.Name))
'■検索対象ファイル '■例)MP3とWAVとWMAファイルを検索対象ファイルにする時 →If sExt="mp3" Or sExt="wav" Or sExt="wma" Then '■例)MP3ファイルを検索対象ファイルにする時 →If sExt="mp3" Then If sExt="mp3" Or sExt="wav" Or sExt="wma" Then
ts.WriteLine oFile.Path End If Next For Each oSubFolder In Folder.SubFolders Call MakeList(oSubFolder) Next
dim objWs,objShell,objFs set objWs=CreateObject("WScript.Shell") set objShell=CreateObject("Shell.Application") set objFs=CreateObject("Scripting.FileSystemObject")
objWs.Run chr(34)& str_donutp_path &chr(34)&" about:blank" do until objWs.AppActivate("Donut P - [about:blank]") WScript.Sleep 500 loop
dim int_win_num,i dim bln_find dim obj_ie int_win_num=objShell.Windows().Count bln_find=false for i=0 to int_win_num-1 set obj_ie=objShell.Windows().Item(i) if StrComp(obj_ie.FullName,str_donutp_path,vbTextCompare)=0 then if obj_ie.LocationName="about:blank" then bln_find=true exit for end if end if next if bln_find=false then msgbox "IEオブジェクトを Getできません" WScript.Quit() end if
'続き dim str_lst_path,str_url dim obj_text str_lst_path=objFs.BuildPath(objFs.GetParentFolderName(WScript.ScriptFullName),str_lst_name) if not objFs.FileExists(str_lst_path) then msgbox "URL リストがありません" WScript.Quit() end if set obj_text=objFs.OpenTextFile(str_lst_path) do until obj_text.AtEndOfStream str_url=obj_text.ReadLine if str_url<>"" then obj_ie.Navigate(str_url) do '読み込み待ち WScript.Sleep 1000 loop until obj_ie.busy=false and obj_ie.ReadyState=4 WScript.Sleep 5000 '5秒毎に巡回 end if loop msgbox "終わり"
set objShell=CreateObject("Shell.Application") msg="" int_win_num=objShell.Windows().Count for i=0 to int_win_num-1 msg=msg & objShell.Windows().Item(i).FullName &vbcrlf next msgbox msg,,int_win_num
On Error Resume Next sPath="D:\Program Files\Internet Explorer\iexplore.exe" Set Shell=Wscript.CreateObject("Shell.Application") iWindow=0 Do sNum=InputBox("現在" & Shell.Windows.Count & "枚のIEとフォルダを開いてる。で、次は何枚開くんだ。",,"1") If IsNumeric(sNum) And sNum<>"" Then For I=1 To CInt(sNum) Shell.ShellExecute sPath,"about:blank" iWindow = iWindow + 1 Next Else Exit Do End If Loop
Dim oIE() Redim oIE(0) Dim iIE iIE=-1 iFol=-1 For Each window In Shell.Windows If typename(window.document)="HTMLDocument" Then iIE=iIE+1 Redim Preserve oIE(iIE) Set oIE(iIE)=window Else iFol=iFol+1 End If Next
iMsg=MsgBox (iIE+1 & "枚のIE、" & iFol+1 & "枚のフォルダウィンドウが開いてる。" & vbCrLf & "IEだけ全部閉じていい?",vbYesNo) If iMsg=vbYes Then For I=0 To UBound(oIE) oIE(I).Quit Next End If
d=0:e=0 title="empty folder search" set a=createobject("scripting.filesystemobject") for each q in createobject("wscript.shell").specialfolders call nosearchlist redim preserve list(n) list(n)=q n=n+1 next for each arg in wscript.arguments if a.folderexists(arg) then call search(a.getfolder(arg),false) args=args&arg&vbcr end if next if args="" then args=left(wscript.scriptfullname,3) call search(a.getfolder(args),true) args=args&vbcr end if msgbox args&"削除を許可されているフォルダ数: "&d&vbcr&"削除したフォルダ数: "&e,4160,title
sub search(t,msg) for each b in t.subfolders if check(b,list2) then d=d+1 if b.subfolders.count<>0 then call search(b,msg) if b.subfolders.count=0 then if -a.fileexists(b&"\desktop.ini")-a.fileexists(b&"\thumbs.db")=b.files.count or b.size=0 then if check(b,list) then if msg then c=msgbox(b&vbcr&"は空です。削除しますか?",4099,title) if (not msg) or c=vbyes then b.delete(true) e=e+1 elseif c=vbcancel then wscript.quit end if end if end if end if end if next end sub
function check(p,data) for each q in data if lcase(q)=lcase(p) then exit function next check=true end function
ElseIf d.DriveType = 1 Then dtype = "Removeable" If d.VolumeName = "" Then dname = " " Else dname = d.VolumeName End If ElseIf d.DriveType = 2 Then dtype = "Fixed" If d.VolumeName = "" Then dname = " " Else dname = d.VolumeName End If ElseIf d.DriveType = 4 Then dtype = "CD-Rom" If d.VolumeName = "" Then dname = " " Else dname = d.VolumeName End If
Outlook.Applicationは、Outlookがインストールされてないと使えません。 Outlook Expressはオートメーションに対応してないのです。残念ながら。 まあ、これが対応していたら、かのI Love Youスクリプトワームの感染力が、 もっと凄まじいものとなっていたことでしょう(w
Dim FSO, Arg, Im, Ex Dim tmp, ln Dim tab, i Set FSO = CreateObject("Scripting.FileSystemObject") Set Arg = WScript.Arguments If Arg.Count > 0 Then For i = 0 To Arg.Count - 1 If FSO.FileExists(Arg(i)) Then tmp = FSO.GetParentFolderName(Arg(i)) & "\temp" FSO.CopyFile Arg(i), tmp Set Im = FSO.OpenTextFile(tmp) Set Ex = FSO.CreateTextFile(Arg(i)) tab = 0 While Not Im.AtEndOfStream ln = Trim(Im.ReadLine) Select Case FirstState(UCase(ln)) Case "DO", "FOR", "FUNCTION", "SELECT", "SUB", "WHILE", "WITH" ln = AddTab(ln, tab) tab = tab + 1 Case "END", "LOOP", "NEXT", "WEND" If tab > 0 Then tab = tab - 1 ln = AddTab(ln, tab) Case "IF" ln = AddTab(ln, tab) If UCase(Right(ln, 4)) = "THEN" Then tab = tab + 1 Case "ELSE", "ELSEIF" ln = AddTab(ln, tab - 1) Case Else ln = AddTab(ln, tab) End Select Ex.WriteLine(ln) Wend
'ファイルのコピー。 If WScript.Arguments.Count = 1 Then Set Shell = Wscript.CreateObject("Shell.Application") Set oFolder = Shell.BrowseForFolder(0,"選択した項目をフォルダにコピーします:", _ BIF_RETURNFSANCESTORS + BIF_USENEWUI) If Not oFolder Is Nothing Then oFolder.CopyHere WScript.Arguments(0),FOF_MULTIDESTFILES + FOF_RENAMEONCOLLISION + FOF_ALLOWUNDO Else WScript.Quit End If End If
'ファイルの移動 If WScript.Arguments.Count = 1 Then Set Shell = Wscript.CreateObject("Shell.Application") Set oFolder = Shell.BrowseForFolder(0,"選択した項目をフォルダに移動します:", _ BIF_RETURNFSANCESTORS + BIF_USENEWUI) If Not oFolder Is Nothing Then oFolder.MoveHere WScript.Arguments(0),FOF_MULTIDESTFILES + FOF_RENAMEONCOLLISION + FOF_ALLOWUNDO Else WScript.Quit End If End If
If Fs.FileExists("2channel.brd") Then Set ts = Fs.OpenTextFile("2channel.brd") Do Until ts.AtEndOfStream aIta = Split(ts.ReadLine,vbTab) If UBound(aIta) = 3 Then sItaURL = "http://" & aIta(1) & "/" & aIta(2) & "/" If Not dicItaURL.Exists(aIta(3)) Then dicItaURL.Add aIta(3),sItaURL End If If Not dicItaName.Exists(aIta(2)) Then dicItaName.Add aIta(2),aIta(3) End If End If Loop ts.Close End If
If Fs.FileExists("favboard.idx") Then Set ts = Fs.OpenTextFile("favboard.idx") Do Until ts.AtEndOfStream sItaName = ts.ReadLine If dicItaURL.Exists(sItaName) Then sItaURLTruePath = Fs.BuildPath(sRootFolder,FixTitle(sItaName) & ".url") ForceCreateFolder Fs.GetParentFolderName(sItaURLTruePath) Set oSc = WshShell.CreateShortcut(sItaURLTruePath) oSc.TargetPath = dicItaURL.Item(sItaName) oSc.Save End If Loop ts.Close End If
If Fs.FileExists(sTruePath) Then Set tsSure = Fs.OpenTextFile(sTruePath) Do Until tsSure.AtEndOfStream aLine = Split(tsSure.ReadLine,vbTab) sURLPath = sItaName & "\" & FixTitle(aLine(3)) & ".url" Loop tsSure.Close Else sURLPath = sItaName & "\" & Fs.GetBaseName(aPath(2)) & ".url" End If If Not dicURL.Exists(sURLPath) Then dicURL.Add sURLPath,sURL End If Loop ts.Close End If
For Each key In dicURL.Keys sURLTruePath = Fs.BuildPath(sRootFolder,key) ForceCreateFolder Fs.GetParentFolderName(sURLTruePath) Set oSc = WshShell.CreateShortcut(sURLTruePath) oSc.TargetPath = dicURL.Item(key) oSc.Save Next
Function FixTitle(title) tmpstr=Split("\ / : , . ; * ? "" < > |"," ") FixTitle=title For Each I In tmpstr Fixtitle=Replace(FixTitle,I,"-") Next End Function
Sub ForceCreateFolder(Folder) If Fs.FolderExists(Folder) Then Exit Sub sParent = Fs.GetParentFolderName(Folder) Call ForceCreateFolder(sParent) Fs.CreateFolder(Folder) End Sub
Set TLI = WScript.CreateObject("TLI.TLIApplication") Set oTypeInfos = TLI.TypeLibInfoFromFile("wshom.ocx").TypeInfos on error resume next For Each oTypeInfo In oTypeInfos For Each oMember In oTypeInfo.Members s = s & oMember.Name & ";" & oTypeInfo.Name & "." & oMember.Name & "(" For Each oParameter In oMember.Parameters s=s & oParameter.Name & ", " Next s = s & ")" & vbCrLf Next Next wscript.Echo s
Set TLI = WScript.CreateObject("TLI.TLIApplication") Set oTypeInfos = TLI.TypeLibInfoFromFile("wshom.ocx").TypeInfos on error resume Next
For Each oTypeInfo In oTypeInfos For Each oMember In oTypeInfo.Members s = s & oMember.Name & ";" & oTypeInfo.Name & "." & oMember.Name & "(" param = "" For Each oParameter In oMember.Parameters Set oVarTypeInfo = oParameter.VarTypeInfo sVarType = GetTypeName(oVarTypeInfo.VarType) If param = "" Then If oParameter.Optional Then param = param & "[" & oParameter.Name & sVarType & "]" Else param = param & oParameter.Name & sVarType End If Else If oParameter.Optional Then param = param & "[, " & oParameter.Name & sVarType & "]" Else param = param & ", " & oParameter.Name & sVarType End If End If Next s = s & param & ")" & GetTypeName(oMember.ReturnType) & ";" & oMember.HelpString & vbCrLf Next Next
Function GetTypeName(TliVarType) Select Case TliVarType Case 8192 : sTemp = "Array" Case 70 : sTemp = "Object" Case 11 : sTemp = "Boolean" Case 8 : sTemp = "String" Case Else GetTypeName="" Exit Function End Select GetTypeName = " As " & sTemp End Function
>>838 //.html をこのスクリプトに Drop //置換して上書きします。"逆の操作" にすると元に戻します //(注) 元に戻らない場合もあります
var w=WSH; if(0==w.Arguments.length) w.echo('引数がありません'),w.quit(); var objFs=new ActiveXObject('Scripting.FileSystemObject'); var str_arg=w.Arguments.Item(0); if(!objFs.FileExists(str_arg) || 'html'!=objFs.GetExtensionName(str_arg).toLowerCase()) w.echo('引数は無効です'),w.quit();
var obj_text=objFs.OpenTextFile(str_arg,1); //読込み open var str_text=obj_text.ReadAll(); obj_text.Close();
str_text=str_text.replace(/[^\n](<dt>)/ig,'\r\n$1'); //<dt>の前にCRLFを付加する //str_text=str_text.replace(/\r\n(<dt>)/ig,'$1'); //逆の操作 obj_text=objFs.OpenTextFile(str_arg,2); //書込み open obj_text.Write(str_text); obj_text.Close();
>>866 Dim FSO, filename, buf(), F, i, s Set FSO = CreateObject("Scripting.FileSystemObject") filename = "hoge.ini" Set F = FSO.OpenTextFile(filename,1) ReDim buf(0) While Not F.AtEndOfStream s = F.ReadLine If s = "piyo=0" Then s = "piyo=1" ElseIf s = "piyo=1" Then s = "piyo=0" End If buf(UBound(buf)) = s ReDim Preserve buf(UBound(buf)+1) Wend F.Close Set F = FSO.CreateTextFile(filename,True) For i = 0 To UBound(buf) - 1 F.WriteLine buf(i) Next F.Close
var w=WScript; if(0==w.Arguments.length) w.echo('引数がありません'),w.quit(); var objFs=new ActiveXObject('Scripting.FileSystemObject'); var objWs=new ActiveXObject('WScript.Shell');
var str_arg=sub_getTarget(w.Arguments.Item(0)); if(!objFs.FileExists(str_arg) || !/\.html$/i.test(str_arg)) w.echo('引数は無効です'),w.quit();
var obj_text=objFs.OpenTextFile(str_arg,1); //読込み open var str_text=obj_text.ReadAll(); obj_text.Close();
set b=createobject("wscript.shell") if wscript.arguments.count<>0 then createobject("scripting.filesystemobject").deletefile b.specialfolders("recent")&"\*" else b.run """"&wscript.scriptfullname&""" -"
set a=wscript.arguments if a.count<>1 then wscript.quit set b=createobject("shell.application") set c=b.windows d=a.item(0) b.open d wscript.sleep(3000) do for each q in c wscript.sleep(500) with q l=.LocationURL m=l for p=1 to len(l) if mid(l,p,1)="%" then r=mid(l,p,3) e=dec(right(r,2)) if e<>0 then m=replace(m,r,chr(e)) p=p+3 end if next if m="file:///"&replace(d,"\","/") then .Height=60 .Width=350 .AddressBar=false .MenuBar=false .ToolBar=false .StatusBar=false wscript.quit end if end with next loop
function dec(c) for q=1 to len(c) p=mid(c,q,1) select case ucase(p) case "A" p=10 case "B" p=11 case "C" p=12 case "D" p=13 case "E" p=14 case "F" p=15 end select if isnumeric(p)=false then errorlevel=1 exit for end if t=(p*16^(len(c)-q))+t next dec=t if errorlevel=1 then dec=0 end function
set s=createobject("scripting.filesystemobject") do h="" for t=1 to 8 randomize timer h=h& hex(int(16*rnd)) next s.createtextfile("a:\"&chr(254)&h&".txt").close loop