Const ForReading = 1, ForWriting = 2, ForAppending = 8 Dim fs Dim f Dim file_name
Set Ie = WScript.CreateObject("InternetExplorer.Application") Ie.Navigate "about:blank" Set oClip=Ie.Document.parentWindow.clipboardData sData=oClip.getData("text") If IsNull(sData) Then sData="" file_name = InputBox("ファイル名を入力してください") Set fs = CreateObject("Scripting.FileSystemObject") set f = fs.CreateTextFile(file_name+".txt", True)
Set Fs = WScript.CreateObject("Scripting.FileSystemObject") Set Ie = WScript.CreateObject("InternetExplorer.Application") Ie.Navigate "about:blank" Do While Ie.Busy Wscript.Sleep 10 Loop Set oClip=Ie.Document.parentWindow.clipboardData sData=oClip.getData("text") If IsNull(sData) Or sData="" Then WScript.Quit
sTitle = Left(sData,15) If InStr(sTitle,vbCrLf)<>0 Then sTitle = Left(sTitle,InStr(sTitle,vbCrLf)) End If
If Not Fs.FileExists(sFileName) Then Set ts = Fs.CreateTextFile (sFileName) ts.Write sData ts.Close End If
Function FixTitle(title) tmpstr=Split("\ / : , . ; * ? "" < > |"," ") FixTitle=title For Each I In tmpstr Fixtitle=Replace(FixTitle,I,"-") Next End Function
Set Fs = WScript.CreateObject("Scripting.FileSystemObject") Set Ie = WScript.CreateObject("InternetExplorer.Application") Ie.Navigate "about:blank" Do While Ie.Busy Wscript.Sleep 10 Loop Set oClip=Ie.Document.parentWindow.clipboardData sData=oClip.getData("text") If IsNull(sData) Or sData="" Then WScript.Quit
sTitle = Left(sData,25) If InStr(sTitle,vbCrLf)<>0 Then sTitle = Left(sTitle,InStr(sTitle,vbCrLf)) End If
If Not Fs.FileExists(sFileName) Then Set ts = Fs.CreateTextFile (sFileName) ts.Write sData ts.Close End If
Function FixTitle(title) tmpstr=Split("\ / : , . ; * ? "" < > |"," ") FixTitle=title For Each I In tmpstr Fixtitle=Replace(FixTitle,I,"-") Next End Function
Set Ie = WScript.CreateObject("InternetExplorer.Application") Set Iria = WScript.CreateObject("Iria.IriaApi") sURL="適当なURL"
Ie.Navigate sURL Do While IE.Busy Or IE.ReadyState<>4 WScript.Sleep 100 Loop Set document=IE.document Set window=document.ParentWindow sURLs=sURL & vbCrLf For Each oSubLink In document.links sURL=oSubLink.href sExt=Right(sURL,3) If sExt="jpg" Or sExt="png" Or sExt="zip" Or sExt="lzh" Then sURLs=sURLs & sURL & vbCrLf End If Next Iria.AddUrl sUrls,0
>>26 Set Fs = WScript.CreateObject("Scripting.FileSystemObject") sFolder="フォルダ名" sListFile=sFolder & "\" & "list.m3u" Set ts=Fs.CreateTextFile(sListFile) For Each oFile In Fs.GetFolder(sFolder).Files sExt=LCase(Fs.GetExtensionName(oFile.Name)) If sExt="mp3" Or sExt="wav" Or sExt="wma" Then ts.WriteLine oFile.Path End If Next ts.Close
Dim WSHShell,WSHSfolder,strList,strFolder Set WSHShell = WScript.CreateObject("WScript.Shell") Set Fs = WScript.CreateObject("Scripting.FileSystemObject") Set WSHSfolder = WSHShell.SpecialFolders sFolder=WSHSfolder("MyDocuments") & "\My Music" sListFile=sFolder & "\" & "list.m3u" Set ts=Fs.CreateTextFile(sListFile) For Each oFile In Fs.GetFolder(sFolder).Files sExt=LCase(Fs.GetExtensionName(oFile.Name)) If sExt="mp3" Or sExt="wav" Or sExt="wma" Then ts.WriteLine oFile.Path End If Next ts.Close
>>30 Dim ts Set Fs = WScript.CreateObject("Scripting.FileSystemObject") sFolder="フォルダ名" sListFile="list.m3u" Set ts=Fs.CreateTextFile(sListFile) Call MakeList(Fs.GetFolder(sFolder))
ts.Close MsgBox "終了"
Sub MakeList(Folder) For Each oFile In Folder.Files sExt=LCase(Fs.GetExtensionName(oFile.Name)) 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 End Sub
>>36 Dim ts,sList Set Fs = WScript.CreateObject("Scripting.FileSystemObject") Randomize sFolder="フォルダ名" sListFile="list.m3u" Call MakeList(Fs.GetFolder(sFolder)) 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(sListFile) ts.Write sList ts.Close MsgBox "終了"
Sub MakeList(Folder) For Each oFile In Folder.Files sExt=LCase(Fs.GetExtensionName(oFile.Name)) If sExt="mp3" Or sExt="wav" Or sExt="wma" Then sList = sList & oFile.Path & vbCrLf End If Next For Each oSubFolder In Folder.SubFolders Call MakeList(oSubFolder) Next End Sub
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 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 & "個のフォルダは空ではないです。"
'吸出しの巻物 '使用法: wscript.exe suidashi.vbs フォルダ名1 [フォルダ名2] ... 'フォルダを指定すると、そのフォルダ内にあるファイルとフォルダを上位フォルダに移動します。 Dim iLeft,iMove,bDel Set Fs = WScript.CreateObject("Scripting.FileSystemObject") iLeft=0 : iMove=0 : bDel=True For Each source In WScript.Arguments If Fs.FolderExists(source) Then target=Fs.BuildPath(Fs.GetParentFolderName(source),"\") If Fs.FolderExists(target) Then Set oTarget=Fs.GetFolder(source) For Each oFile In oTarget.Files If Fs.FileExists(Fs.BuildPath(target,oFile.Name)) Then 'すでに存在。移動中止。 iLeft=iLeft+1 Else oFile.Move target iMove=iMove+1 End If Next For Each oFolder In oTarget.SubFolders If Fs.FolderExists(Fs.BuildPath(target,oFolder.Name)) Then 'すでに存在。移動中止。 iLeft=iLeft+1 Else oFolder.Move target iMove=iMove+1 End If Next If bDel=True Then If oTarget.Files.Count=0 And oTarget.SubFolders.Count=0 Then oTarget.Delete End If End If End If Next
For Each sArg In WScript.Arguments '引数として指定したフォルダを処理対象にする。 If Fs.FolderExists(sArg) Then Call MakeList(Fs.GetFolder(sArg)) End If Next
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(sListFile) ts.Write sList ts.Close MsgBox "終了"
まず、↓をtranslate.htmとして保存 <script language="vbscript"> <!-- Set oTextRange = external.menuArguments.document.selection.createRange strTranslate = oTextRange.text a=Asc(Left(strTranslate,1)) If 0<= a And a<=255 Then mode="ENJA" Else mode="JAEN" End If strURL = "http://www.excite.co.jp/world/text/?wb_lp=" & mode & "&before=" & strTranslate Set objIE = CreateObject("InternetExplorer.Application") With objIE Call .Navigate2( strURL ) .Visible = False Do While .Busy Or .ReadyState<>4
Loop strRet = strTranslate & "を翻訳すると…" & vbCrLf & .document.World.after.Value Call .Quit() End With Set objIE = Nothing window.alert strRet --> </script>
Set HTTP = WScript.CreateObject("Microsoft.XMLHTTP") Set Stream = WScript.CreateObject("Adodb.Stream") Set Fs = WScript.CreateObject("Scripting.FileSystemObject") Set Shell = WScript.CreateObject("Shell.Application")
Set regEx = New RegExp regEx.IgnoreCase = True regEx.Global = True
For Each Process In GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_Process where Name='Katjusha.exe'") Set oProcess = Process sEXEPath=oProcess.ExecutablePath Next If IsEmpty(oProcess) Then MsgBox "かちゅ〜しゃが起動されていません!" WScript.Quit End If
sRoot = Fs.GetParentFolderName(sEXEPath) sDLLPath = Fs.BuildPath(sRoot,DLLName) If Fs.FileExists(sDLLPath) Then dDateLastModified=Fs.GetFIle(sDLLPath).DateLastModified iMsg=MsgBox ("現在、ksock32.dll ver" & Fs.GetFileVersion(sDLLPath) & "(最終更新日時: " & CStr(dDateLastModified) & ")がインストールされています。" & vbCrLf & _ "最新バージョンをチェックしますか?",vbYesNo) If iMsg=vbNo Then WScript.Quit
HTTP.Open "HEAD", URL, False HTTP.Send regEx.Pattern = "\nLast-Modified\: .{3}, (\d{1,}) (.{3}) (\d{4}) (\d{1,})\:(\d{1,})\:(\d{1,}) .{3}\r\n" Set Matches = regEx.Execute(HTTP.getAllResponseHeaders) For Each Match in Matches Set Subs = Match.SubMatches dServerDateLastModified=CDate(Subs(2) & "/" & GetMonthNumber(Subs(1)) & "/" & Subs(0) & " " & Subs(3) & ":" & Subs(4) & ":" & Subs(5)) Next
If DateDiff ("s",dServerDateLastModified,dDateLastModified) < 0 Then iMsg=MsgBox ("ksock32.dllは更新されているようです。ダウンロードしてインストールしますか?",vbYesNo) Else iMsg=MsgBox ("ksock32.dllは更新されていないようです。それでもダウンロードしてインストールしますか?",vbYesNo) End If Else iMsg=MsgBox ("ksock32.dllをダウンロードしてインストールしますか?",vbYesNo) End If
If iMsg=vbOK Then For Each Process In GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_Process where Name='Katjusha.exe'") Process.Terminate Next Else WScript.Quit End If
iMsg=MsgBox ("ksock32.dllのダウンロードを開始します。" & vbCrLf & _ "次にダイアログが表示されるまでは、かちゅ〜しゃを起動しないでください。",vbOkCancel) If iMsg=vbCancel Then WScript.Quit
Function GetMonthNumber(MonthName) Select Case MonthName Case "Jan" GetMonthNumber="01" Case "Feb" GetMonthNumber="02" Case "Mar" GetMonthNumber="03" Case "Apr" GetMonthNumber="04" Case "May" GetMonthNumber="05" Case "Jun" GetMonthNumber="06" Case "Jul" GetMonthNumber="07" Case "Aug" GetMonthNumber="08" Case "Sep" GetMonthNumber="09" Case "Oct" GetMonthNumber="10" Case "Nov" GetMonthNumber="11" Case "Dec" GetMonthNumber="12" End Select End Function
Dim fileObj, n Set fileObj = WScript.CreateObject("WScript.Shell") fileObj.Run "c:\**********exe" WScript.Sleep 7000 '起動するまでの待ち時間 For n=100 To 999 Step 1 fileObj.SendKeys n fileObj.SendKeys "{ENTER}" WScript.Sleep 1 fileObj.SendKeys "{ENTER}" fileObj.SendKeys "{BS}" fileObj.SendKeys "{BS}" fileObj.SendKeys "{BS}" Next
function downloadFile(savePath, url) { var adTypeBinary = 1; var adSaveCreateNotExist = 1; var adSaveCreateOverWrite = 2;
var objXmlHttp = WScript.CreateObject("Microsoft.XMLHTTP"); var objStream = WScript.CreateObject("Adodb.Stream"); var objFs = WScript.CreateObject("Scripting.FileSystemObject");
// セーブフォルダがなかったら作る var parentFolder = objFs.GetParentFolderName(savePath); if (objFs.FolderExists(parentFolder) == false) objFs.CreateFolder(parentFolder);
// 親URLをreferにする var spos = url.lastIndexOf("/"); var parentUrl = url.substring(0, spos);
Set Ie = WScript.CreateObject("InternetExplorer.Application") Ie.Navigate "about:blank" Do While Ie.Busy Wscript.Sleep 10 Loop Set oClip=Ie.Document.parentWindow.clipboardData oClip.setData "text","test"
<SCRIPT LANGUAGE="VBScript"> Set ie = CreateObject("InternetExplorer.Application") Set win = external.menuArguments Set rng = win.document.selection.createRange()
ie.Navigate "about:blank" Do While Ie.Busy Wscript.Sleep 10 Loop
Set oClip = ie.Document.parentWindow.clipboardData sData = oClip.getData("text") If IsNull(sData) Then sData = ""
Dim intStart Dim intEnd Dim intLength Dim strResult
intStart = 1 Do While intStart < Len(sData) intEnd = InStr(intStart,sData,VbCrLf,vbTextCompare) If intEnd = 0 Then strTemp = Mid(sData,intStart) If strTemp <> "" Then strResult = strResult & "> " & strTemp Exit Do Else intLength = intEnd + Len(VbCrLf) - intStart strTemp = "> " & Mid(sData,intStart,intLength) intStart = intEnd + Len(VbCrLf) strResult = strResult & strTemp End If Loop
<SCRIPT LANGUAGE="JScript"> var oWin = external.menuArguments; var oShell = new ActiveXObject("WScript.Shell"); var strProtocol = "file:////"; var strData = new String(oWin.document.location.href);
↓newie.htmとしてD:\\ieplugin\\newie.htmに保存 <HTML> <SCRIPT LANGUAGE="JavaScript" defer> var parentwin = external.menuArguments; var doc = parentwin.document; var sel = doc.selection; var rng = sel.createRange(); var str = rng.text.replace(/http:\/\/|ttp:\/\/|http:\/\/|htp:\/\/|htt:\/\//, "");
if (str=="") alert ("You must select some text to search for first."); else open("http://" + str);
var urlList = new Array(); expandUrl(urlList, "www.hogehoge.com/[01-03]/[03-05].jpg"); WScript.echo(urlList);
function expandUrl(urlList, url) { var re = new RegExp("[[]([0-9]+)-([0-9]+)[]]"); var arr = re.exec(url);
if (arr == null) { urlList.push(url); return; }
var beginStr = RegExp.$1; //エイリアス var begin = parseInt(RegExp.$1); var end = parseInt(RegExp.$2); var leftContext = new String(RegExp.leftContext); var rightContext = new String(RegExp.rightContext);
' ///////////////////////////////////////////////////////////// ' // ヘルパー関数 ' ハード リンクを作成する '------------------------------------------------------------ function QueryForHardLink(sTargetFile) ' コマンド ラインで指定された場合にハード リンク名を取得する dim sHardLinkName if WScript.Arguments.Count >1 then sHardLinkName = WScript.Arguments(1) else dim buf buf = L_EnterHardLink & " for" & vbCrLf & sTargetFile sHardLinkName = InputBox(buf, L_HardLinks, sTargetFile) if sHardLinkName = "" then WScript.Quit if sHardLinkName = sTargetFile then MsgBox L_SameName exit function end if end if
'両ファイルが同じボリュームにあるか 'そのボリュームが NTFS であるかを確認する if Not CanCreateHardLinks(sTargetFile, sHardLinkName) then MsgBox L_CannotCreate exit function end if
' ハード リンクを作成する dim oHL set oHL = CreateObject("HardLink.Object.1") oHL.CreateNewHardLink sHardLinkName, sTargetFile end function
// メールサービスへのリンクを探す for(var en = new Enumerator(objIE.document.links); !en.atEnd(); en.moveNext()) { var linkText = en.item().toString(); var index = linkText.indexOf("view=mail");
if (index >= 0) { objIE.navigate(linkText); break; } }
function waitForLoad(objIE) { while (objIE.busy) WScript.Sleep(10); while (objIE.Document.readyState != "complete") WScript.Sleep(10); }
Win2000専用で、しかも結構タイミング的に動かないこともある スクリプト。接続中なら切断、切断中なら接続します。 ちょっと書き変えれば、任意の接続先に接続するとかもできます。 Set Shell = WScript.CreateObject("Shell.Application") For Each oItem In Shell.NameSpace(3).Items If oItem.Name="ネットワークとダイヤルアップ接続" Then Set oFolder=oItem.GetFolder For Each oSubItem In oFolder.Items If oFolder.GetDetailsOf(oSubItem,1)="ダイヤルアップ" Then If oFolder.GetDetailsOf(oSubItem,2)="接続" Then WScript.Sleep 500 oSubItem.InvokeVerb "切断(&O)" WScript.Sleep 500 Else WScript.Sleep 500 oSubItem.InvokeVerb "接続(&O)" WScript.Sleep 500 End If Exit For End If Next Exit For End If Next
'arrfol.vbs Set Fs = WScript.CreateObject("Scripting.FileSystemObject") sRoot=WScript.Arguments(0) For Each oFile In Fs.GetFolder(sRoot).Files sBase=Fs.GetBaseName(oFile.Name) For I=1 To Len(sBase) If Not IsNumeric(Right(sBase,I)) Then If I=1 Then Exit For sFol = Left(sBase,Len(sBase) - I+1) If Right(sFol,1)="-" Or Right(sFol,1)="_" Or Right(sFol,1)=" " Then sFol = Left(sFol,Len(sFol)-1) End If sPath = sRoot & "\" & sFol & "\" If Not Fs.FolderExists(sPath) Then Fs.CreateFolder(sPath) sNewFile=Fs.BuildPath(sPath,oFile.Name) If Not Fs.FileExists(sNewFile) Then oFile.Move sPath Else If oFile.Size=Fs.GetFile(sNewFile).Size Then oFile.Delete End If End If Exit For End If Next Next MsgBox "終了"
var en = new Enumerator(parentFolder.Files); for (; !en.atEnd(); en.moveNext()) { var newFileName = parentFolder.Name + "_" + en.item().Name; var newFilePath = objFs.buildPath(targetFolder.Path, newFileName);
if (!objFs.fileExists(newFilePath)) en.item().move(newFilePath); }
en = new Enumerator(parentFolder.SubFolders); for (; !en.atEnd(); en.moveNext()) { var newFileName = parentFolder.Name + "_" + en.item().Name; var newFilePath = objFs.buildPath(targetFolder.Path, newFileName);
if (!objFs.fileExists(newFilePath)) en.item().move(newFilePath); }
すみません。>>224 の修正です。 var en = new Enumerator(parentFolder.Files); for (; !en.atEnd(); en.moveNext()) { var newFileName = parentFolder.Name + "_" + en.item().Name; var newFilePath = objFs.buildPath(targetFolder.Path, newFileName);
if (!objFs.fileExists(newFilePath)) en.item().move(newFilePath); }
en = new Enumerator(parentFolder.SubFolders); for (; !en.atEnd(); en.moveNext()) { var newFolderName = parentFolder.Name + "_" + en.item().Name; var newFolderPath = objFs.buildPath(targetFolder.Path, newFolderName);
WScript.echo(newFolderPath);
if (!objFs.FolderExists(newFolderPath)) en.item().move(newFolderPath); }
Set WshShell = WScript.CreateObject("WScript.Shell") Set Fs = WScript.CreateObject("Scripting.FileSystemObject") Set regEx = New RegExp regEx.IgnoreCase = True regEx.Global = False
For Each sArg In WScript.Arguments If Fs.FileExists(sArg) And LCase(Fs.GetExtensionName(sArg))="lnk" Then Set oShortCut=WshShell.CreateShortcut(sArg) With oShortCut sTargetPath=.TargetPath If LCase(Fs.GetFileName(sTargetPath)) = "cmd.exe" Then regEx.Pattern="\/([RHANBL]\S*)" Set Matches =regEx.Execute (.Arguments) For Each Match In Matches sPriorityAccessKey = Left(Match.SubMatches(0),1) Next regEx.Pattern="cmd.*\s\/[RHANBL]\S*\s+(.*)" Set Matches =regEx.Execute (.Arguments) For Each Match In Matches sProgArg =Match.SubMatches(0) Next Else sPriorityAccessKey = "N" sProgArg = RTrim(sTargetPath & " " & .Arguments) End If
Select Case sPriorityAccessKey Case "R" : sPriority="REAL" Case "H" : sPriority="HIGH" Case "A" : sPriority="ABOVENORMAL" Case "N" : sPriority="NORMAL" Case "B" : sPriority="BELOWNORMAL" Case "L" : sPriority="LOW" Case Else : sPriority="" End Select
If sPriority<>"" Then If LCase(Fs.GetFileName(sTargetPath)) = "cmd.exe" Then If sPriorityAccessKey<>"N" Then regEx.Pattern="\/([RHANBL]\S*)" .Arguments=regEx.Replace (.Arguments, "/" & sPriority) .Save Else MsgBox "通常のショートカットに戻す処理は未実装です。" '(めんどくさいので。要望があったら書くけど) regEx.Pattern="\/([RHANBL]\S*)" .Arguments=regEx.Replace (.Arguments, "/" & sPriority) .Save End If
ElseIf sPriorityAccessKey<>"N" Then iWindowStyle= .WindowStyle Select Case iWindowStyle Case 3 : sWindowStyleOpt=" /MAX " Case 7 : sWindowStyleOpt=" /MIN " Case Else : sWindowStyleOpt="" End Select .WindowStyle= 7 'MIN .Arguments = RTrim("cmd /c start /d" & .WorkingDirectory & sWindowStyleOpt & " /" & sPriority & " " & sTargetPath & " " & .Arguments) .TargetPath = "cmd.exe" If .IconLocation=",0" Then .IconLocation = sTargetPath & ",0" End If .Save End If End If End With End If Next
var objFs = new ActiveXObject("Scripting.FileSystemObject");
var enArgs = new Enumerator(WScript.Arguments); for (; !enArgs.atEnd(); enArgs.moveNext()) { var parentFolderPath = enArgs.item(); if (objFs.FolderExists(parentFolderPath)) { var parentFolder = objFs.GetFolder(parentFolderPath); var granpaFolderPath = objFs.GetParentFolderName(parentFolderPath);
var en = new Enumerator(parentFolder.Files); for (; !en.atEnd(); en.moveNext()) { var newFileName = parentFolder.Name + separator + en.item().Name; var newFilePath = objFs.buildPath(granpaFolderPath, newFileName);
if (!objFs.fileExists(newFilePath)) en.item().move(newFilePath); }
en = new Enumerator(parentFolder.SubFolders); for (; !en.atEnd(); en.moveNext()) { var newFolderName = parentFolder.Name + separator + en.item().Name; var newFolderPath = objFs.buildPath(granpaFolderPath, newFolderName);
if (!objFs.FolderExists(newFolderPath)) en.item().move(newFolderPath); }
//////////////// config //////////////////////// var queueFilePath = "C:\\downloads\\queue.irv"; ////////////////////////////////////////////////
var text = external.menuArguments.document.selection.createRange().text; var str = text.replace(/^.*:\/\//, ""); str = str.replace("和塩", "www.geocities.co.jp"); str = str.replace("米塩", "www.geocities.com"); str = str.replace("和鳥", "www.toripod.co.jp"); str = str.replace("米鳥", "www.toripod.com");
if (str=="") alert ("You must select some text to search for first."); else { var url = "http://" + str; var ForReading = 1, ForWriting = 2, ForAppending = 8; var TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0;
var objFs = new ActiveXObject("Scripting.FileSystemObject"); objFs.CreateTextFile(queueFilePath); var file = objFs.GetFile(queueFilePath); var fout = file.OpenAsTextStream(ForWriting, TristateUseDefault);
var urlList = new Array(); expandUrl(urlList, url);
while (urlList.length > 0) fout.Write(makeIrvineQueue(urlList.pop()));
fout.Close(); }
function makeIrvineQueue(url) { var re = new RegExp("([^/]+)/([^/]+)$"); var arr = re.exec(url);
function expandUrl(urlList, url) { var re = new RegExp("[[]([0-9]+)-([0-9]+)[]]"); var arr = re.exec(url);
if (arr == null) { urlList.push(url); return; }
var beginStr = RegExp.$1; //エイリアス var begin = parseInt(RegExp.$1); var end = parseInt(RegExp.$2); var leftContext = new String(RegExp.leftContext); var rightContext = new String(RegExp.rightContext);
Set HTTP = WScript.CreateObject("Microsoft.XMLHTTP") Set Stream = WScript.CreateObject("Adodb.Stream") Set Fs = WScript.CreateObject("Scripting.FileSystemObject") Set Shell = WScript.CreateObject("Shell.Application")
Function GetHTMLDocument(sURL,sFileName) On Error Resume Next Set Fs = WScript.CreateObject("Scripting.FileSystemObject") Set xh = WScript.CreateObject("microsoft.xmlhttp") xh.Open "GET", sURL, False xh.Send If Err.Number<> 0 Then sErr=sErr & sURL & ": " & Err.Description GetHTMLDocument="" Exit Function End If On Error Goto 0 Set ts=Fs.CreateTextFile(sFileName,True,True) 'UNICODEとして書き込む ts.Write xh.responseBody ts.Close Set ts=Fs.OpenTextFile(sFileName,1,False,0) 'SJISとして読む If Not ts.AtEndOfStream Then ts.Read(2) '2バイトのごみ(UNICODEヘッダ?) If Not ts.AtEndOfStream Then sTempStr = ts.ReadAll End If End If ts.Close Set ts=Fs.CreateTextFile(sFileName,True,False) 'SJISとして保存 ts.Write sTempStr ts.Close GetHTMLDocument=sTempStr End Function
set objWSHController = WScript.CreateObject("WSHController") set objRemoteProcess = objWSHController.CreateScript("D:\wsh_temp\BeenHere.wsf", "TEST_SRV")
objRemoteProcess.Execute
While objRemoteProcess.Status <> 2 WScript.Sleep 100 WEnd
WScript.Echo "Done" </script> </job> </package>
'リモート実行スクリプト(ローカルのD:\wsh_temp\BeenHere.wsf) <package> <job> <script language="VBScript"> set fso = CreateObject("Scripting.FileSystemObject") set fout = fso.CreateTextFile("d:\dbtest\beenhere.txt", true) fout.WriteLine Now fout.Close </script> </job> </package>
<script language="JScript"> var oTextRange = external.menuArguments.document.selection.createRange(); var sBefore = oTextRange.text; var IE = new ActiveXObject("InternetExplorer.Application") var re = /%u/m; if (re.test(escape(sBefore))) { var mode="JAEN"; } else { var mode="ENJA"; } sURL = "http://www.excite.co.jp/world/text/?wb_lp=" + mode + "&before=" + encodeURIComponent(sBefore); IE.Navigate (sURL); // IE.Visible = true; var intervalID = setInterval("CheckBusy()",100);
function CheckBusy() { if ((!IE.Busy) && (IE.ReadyState==4)) { clearInterval(intervalID); alert (IE.document.World.after.Value); } } </script>
for(var en = new Enumerator(objIE.document.all); !en.atEnd(); en.moveNext()) if (en.item().name == "after" ) return decodeURIComponent(en.item().value);
var res = ""; for(var en = new Enumerator(objIE.document.all); !en.atEnd(); en.moveNext()) if (en.item().name == "after" ) { res = decodeURIComponent(en.item().value); }
Dim iRes Set Fs = WScript.CreateObject("Scripting.FileSystemObject") Set WshShell = WScript.CreateObject("WScript.Shell") Set dicIdx = WScript.CreateObject("Scripting.Dictionary") Set regEx = New RegExp regEx.IgnoreCase = True regEx.Global = True
If Not Fs.FileExists("kage.exe") Then MsgBox "かちゅ〜しゃのあるフォルダにおいてください。それとkage導入して。" WScript.Quit End If
If Not Fs.FileExists("kakikomi.txt") THen MsgBox "ROMはお断りだゴルァ" WScript.Quit End If
If Not Fs.FolderExists("log") THen MsgBox "ログがない。" WScript.Quit End If
Set tsKakikomi=Fs.OpenTextFile("kakikomi.txt") sKakikomi=tsKakikomi.ReadAll tsKakikomi.Close
If Not Fs.FolderExists("log\local") Then Fs.CreateFolder "log\local" End If
If Not Fs.FolderExists("log\local\mine") Then Fs.CreateFolder "log\local\mine" End If
For Each sMessage In Split(sKakikomi,vbCrLf & String(44,"-") & vbCrLf) Set Matches=regEx.Execute(sMessage) For Each Match In Matches Set SubMatch=Match.SubMatches sBody=Replace(StrEscape(SubMatch(12)),vbCrLf,"<br>") sBody = sBody & "<a href=""http://" & SubMatch(7) & "/test/read.cgi?bbs=" & _ SubMatch(8) & "&key=" & SubMatch(9) & """ target=""_blank"">" & _ StrEscape(SubMatch(6)) & "</a>"
tsDat.WriteLine "<b>" & SubMatch(10) & "</b>," & SubMatch(11) & "," & _ SubMatch(0) & "/" & SubMatch(1) & "/" & SubMatch(2) & " " & _ SubMatch(3) & ":" & SubMatch(4) & ":" & SubMatch(5) & "," & sBody sIdx=Replace(SubMatch(7),"/","_") & "\" & SubMatch(8) & "\" & SubMatch(9) & ".idx" If Not dicIdx.Exists(sIdx) Then dicIdx.Add sIdx,"" End If Next iRes=iRes+1 Next tsDat.CLose
////// config ////// var saveFileName = "result_of_translate_js.txt"; //////////////////// var ej = 0; var je = 1; var fso = new ActiveXObject("Scripting.FileSystemObject");
for (var args = new Enumerator(WScript.Arguments); !args.atEnd(); args.moveNext()) { // ファイル名・フォルダ名取得 var filename = args.item(); if (!fso.FileExists(filename)) continue;
// テキストファイルのロード var before = loadTextFile(filename); mode = isEnglish(before) ? ej : je;
// 翻訳 var after = translateText(before, mode);
// 保存パス生成 var parentFolder = fso.GetParentFolderName(filename); var saveFilePath = fso.buildPath(parentFolder, saveFileName);
function isEnglish(text) { for (var i = 0; i < text.length; i++) if (text.charCodeAt(i) > 0x7F) return false; return true; }
function loadTextFile(filename) { var ForReading = 1; // var fso = new ActiveXObject("Scripting.FileSystemObject"); var f = fso.OpenTextFile(filename, ForReading); text = f.ReadAll(); f.Close(); return text; }
function saveTextFile(filename, text) { var ForWriting = 2; // var fso = new ActiveXObject("Scripting.FileSystemObject"); var f = fso.OpenTextFile(filename, ForWriting, true); text = f.Write(text); f.Close(); }
// mode : 0->ej, other->je function translateText(before, mode) { var objIE = new ActiveXObject("InternetExplorer.Application");
var res = ""; for(var en = new Enumerator(objIE.document.all); !en.atEnd(); en.moveNext()) if (en.item().name == "after" ) { res = en.item().value; } objIE.Quit(); return res; }
function waitForLoad(objIE) { while (objIE.busy) WScript.Sleep(10); while (objIE.Document.readyState != "complete") WScript.Sleep(10); }
var ej = 0; var je = 1; var fso = new ActiveXObject("Scripting.FileSystemObject");
for (var args = new Enumerator(WScript.Arguments); !args.atEnd(); args.moveNext()) { // ファイル名・フォルダ名取得 var filename = args.item(); if (!fso.FileExists(filename)) continue;
// テキストファイルのロード var before = loadTextFile(filename); mode = isEnglish(before) ? ej : je;
// 翻訳 var lf = before.match(/\x0d\x0a|\x0d|\x0a/); before = before.replace(/\x0d\x0a|\x0d|\x0a/g, "{br}"+lf); var after = translateText(before, mode); after = after.replace(/{br}/g, lf);
// 保存パス生成 var parentFolder = fso.GetParentFolderName(filename); var saveFileName = fso.GetBaseName(filename) +(mode == ej ? "(j)." : "(e).") +fso.GetExtensionName(filename); var saveFilePath = fso.buildPath(parentFolder, saveFileName);
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