Dim Parameters, WSHShell, Fs Set Parameters = WScript.Arguments Set WSHShell = WScript.CreateObject("WScript.Shell") Set Fs = WScript.CreateObject("Scripting.FileSystemObject") Const vbWq = """" Dim win, Explorer, arTargets, iTargets, pTargets(), iRoot, nDT, tFolder, tExec win = WSHShell.ExpandEnvironmentStrings("%systemroot%") Explorer = Fs.BuildPath(win,"Explorer.exe") & " /e," If Parameters.Count = 0 Then iTargets = arIni() ElseIf Parameters.Count = 1 Then iTargets = Split(Parameters(0),",") ElseIf Parameters.Count >=2 Then For Pc = 0 To Parameters.Count - 1 Redim Preserve pTargets(Pc) pTargets(Pc) = Parameters(Pc) Next iTargets = pTargets Else Wscript.Quit End IF lnkChk iTargets, 1, arTargets nDT = iDT("\"," ","",1)(0) For Each iRoot In arTargets If iRoot = "" Then ElseIf Fs.FolderExists(iRoot) Then tFolder = Fs.BuildPath(iRoot,nDT) If Fs.FolderExists(tFolder) Then Else tFolder = iRoot End If tExec = Explorer & tFolder WSHShell.Run tExec, 1 Wscript.Sleep 500 End If Next Set Fs = Nothing Set WSHShell = Nothing Wscript.Quit Function lnkChk(SourceArray,Control,ResultArray) Dim Pc, iSA, eSA, cSA, lPass, ePass, rSAs() Pc = 0 For Each iSA in SourceArray eSA = Ucase(Fs.GetExtensionName(iSA)) cSA = (eSA = "LNK") or ((eSA = "URL") And Control > 0) If cSA Then scGet iSA, lPass ePass = Ucase(Fs.GetExtensionName(lPass)) If ePass = "" Then ElseIf Control >= 2 Then ElseIf ePass = "HTML" And Control >= 1 Then Else lPass = "" End If ElseIf eSA = "" Then lPass = iSA Else lPass = "" End If If lPass = "" Then Else Redim Preserve rSAs(Pc) rSAs(Pc) = lPass Pc = Pc + 1 End If Next ResultArray = rSAs End Function Function scGet(scSource, scResult) Dim tSc If Fs.FileExists(scSource) Then Set tSc = WSHShell.CreateShortcut(scSource) scResult = tSc.TargetPath Set tSc = Nothing Else scResult = "" End If End Function Public Function iDT(dSplitter,dtSeparater,tSplitter,Control) Dim nX, nD, nS, strHMS, sResult nX = Now() nD = FormatDateTime(Date(),0) nS = ":" & Split(CStr(FormatDateTime(nX,3)),":")(2) strHMS = FormatDateTime(nX,4) & nS If tSplitter = ":" Then Else strHMS = Replace(strHMS,":",tSplitter) End If sResult = Cstr(Replace(nD,"/",dSplitter)) & "*" & strHMS If Control = 1 Then iDT = Split(sResult,"*") Else iDT = Replace(sResult,"*",dtSeparater) End If End Function Public Function arIni() Dim sNFull, rFolder, sN, iniFile sNFull = Wscript.ScriptFullName rFolder = Fs.GetParentFolderName(sNFull) sN = Fs.GetBaseName(sNFull) iniFile = Fs.BuildPath(rFolder,sN & ".ini") If Fs.FileExists(iniFile) Then arIni = iniLoader(iniFile,0) Else arIni = Array(rFolder) End If End Function Public Function iniLoader(iniFile, Control) Dim nS nS = Fs.GetFile(iniFile).size If nS = 0 Then iniLoader = Array(Fs.GetParentFolderName(iniFile)) Else Dim iFile, lResult, strResults Set iFile = Fs.OpenTextFile(iniFile,1) WScript.Sleep 150 Do Until iFile.AtEndOfStream lResult = lResult & ";" & iFile.ReadLine & ";" Loop WScript.Sleep 150 iFile.Close strResults = Replace(Replace(lResult,";;",","),";","") If Control = 0 Then iniLoader = Split(strResults, ",") Else iniLoader = strResults End If End If End Function
|
0 件のコメント:
コメントを投稿
注: コメントを投稿できるのは、このブログのメンバーだけです。