Option Explicit
Public My, MySh, Fs, objBoard, objTLib
Public Parameters
Set My = WScript
With My
Set Parameters = .Arguments
Set Fs = .CreateObject("Scripting.FileSystemObject")
Set MySh = .CreateObject("WScript.Shell")
Set objTLib = .CreateObject("Scriptlet.TypeLib")
If IsEmpty(objTLib) Then
exQuit
End If
End With
Public MyNameFull, MyName, MyDoc, MyRoot
MyNameFull = My.ScriptFullName
MyName = Fs.GetBaseName(MyNameFull)
sfSet
MyDoc = Fs.BuildPath(UserProf, "Documents")
MyRoot = "TextFiles\GUID\"
MyRoot = LocSet(MyDoc, MyRoot)
Public vbTc, vbCt, vbWt, vbWq, vbTs, vbCs
vbWq = """"
vbTc = vbTab & vbCrlf
vbCt = vbCrlf & vbTab
vbWt = vbWq & vbTab
vbTs = String(2,vbTab)
vbCs = String(2,vbCrLf)
Dim sPc, Pc, arGUID(), strGUID
Dim sDt, tTe, tFolder, eFolders, sLog, arResult, rFile, strFile
iDT ,"","_","", 0, sDt
If Parameters.Count >= 2 Then
sPc = Parameters(0)
strFile = Parameters(1)
Else
sPc = InputBox("GetCount?", MyName, 1)
If sPc = "" Then
exQuit
End If
strFile = Fs.BuildPath(MyRoot,"gettedGUID_[" & sPc & "]_" & sDT & ".txt")
End If
TextViewer tTe
For Pc = 0 to sPc - 1
Redim Preserve arGUID(Pc)
arGUID(Pc) = getGUID()
Next
Set rFile = Fs.CreateTextFile(strFile,0)
My.Sleep 300
For Each strGUID In arGUID
rFile.WriteLine strGUID
My.Sleep 200
Next
rFile.Close
If tTe = "NotSetting" Then
MySh.Popup eFolders & vbCr & "リスト出力を完了しました。" , 10, MyName, 64
Else
Dim tgtExec
tgtExec = tTe & vbWq & strFile & vbWq
MySh.Run tgtExec, 1
End If
exQuit
Public Win, System, UserProf, Roamings
Function sfSet()
With MySh
Win = .ExpandEnvironmentStrings("%systemroot%")
System = Fs.BuildPath(win,"System32")
UserProf = .ExpandEnvironmentStrings("%UserProfile%")
Roamings = .ExpandEnvironmentStrings("%AppData%")
End With
End Function
Function LocSet(strRoot, strFolders)
Dim strFolder, arTgtFolder, tgtFolder
tgtFolder = strRoot
With Fs
arTgtFolder = Split(strFolders, "\")
For Each strFolder In arTgtFolder
tgtFolder = .BuildPath(tgtFolder, strFolder)
If tgtFolder = "" Then
Else
If .FolderExists(tgtFolder) Then
Else
.CreateFolder tgtFolder
End If
End If
Next
End With
If Right(tgtFolder, 1) = "\" Then
LocSet = tgtFolder
Else
LocSet = tgtFolder & "\"
End If
End Function
Sub exQuit()
Set Parameters = Nothing
Set objTLib = Nothing
Set Fs = Nothing
Set MySh = Nothing
My.Quit
End Sub
Function TextViewer(ResultKey)
Dim sTV, arRep
Const RegKey = "HKCR\txtfile\shell\open\command\"
sTV = MySh.RegRead(RegKey)
sTV = Replace(sTV, vbWq, "")
sTV = Replace(sTV, " %1", "")
sTV = Replace(LCase(sTV), "%systemroot%", "C:\Windows")
If Fs.FileExists(sTV) Then
ResultKey = vbWq & sTv & vbWq & " "
Else
ResultKey = "NotSetting"
End If
End Function
Function getGUID()
Dim setGUID, lenGUID
setGUID = objTLib.GUID
lenGUID = Len(setGUID) - 4
getGUID = Mid(setGUID, 2, lenGUID)
Set objTLib = Nothing
My.Sleep 200
Set objTLib = My.CreateObject("Scriptlet.TypeLib")
End Function
Function getClip(strTarget)
Dim objClip
Set objClip = objBoard.Controls.Add("Forms.TextBox.1").Object
With objClip
.MultiLine = True
.Text = strTarget
.SelStart = 0
.SelLength = .TextLength
.Copy
End With
Set objClip = Nothing
End Function
Public Function iDT(tDateTime, dSplitter, dtSeparater, tSplitter, Control, Result)
Dim vDateTime, cDateTime, nD, nS, strYMD, strHNS
Dim dVal, cVar, arVar
dVal = Array(Now(),"/"," ",":",1)
cVar = Array(Array(tDateTime,7,False,dVal(0)),Array(dSplitter,10,True,dVal(1)), _
Array(dtSeparater,10,True,dVal(2)),Array(tSplitter,10,True,dVal(3)), _
Array(Control,2,False,dVal(4)))
arVar = VarChk(cVar)
tDateTime = arVar(0)
strYMD = FormatDateTime(DateValue(tDateTime),0)
nS = ":" & Split(CStr(FormatDateTime(tDateTime,3)),":")(2)
strHNS = FormatDateTime(tDateTime,4) & nS
If arVar(3) = dVal(3) Then
Else
strHNS = Replace(strHNS,dVal(3),arVar(3))
End If
If arVar(1) = dVal(1) Then
Else
strYMD = Cstr(Replace(strYMD,dVal(1),arVar(1)))
End If
If arVar(4) = dVal(4) Then
Result = Split(strYMD & "|" & strHNS,"|")
Else
Result = strYMD & arVar(2) & strHNS
End If
End Function
Function VarChk(arVar)
If VarType(arVar) >= 8192 Then
ReDim iResult(UBound(arVar))
Dim Pc, iVar, cVar ,vVar, vDT, cDT
Pc = 0
For Each iVar In arVar
cVar = VarType(iVar) >= 8192 And Ubound(iVar) = 3
If cVar Then
cVar = VarType(iVar(1)) = 2 And VarType(iVar(2)) = 11
If cVar Then
If iVar(1) = 8 Then
vDT = VarType(iVar(0))
cDT = vDT <> 10 And (vDT = 7 Or (vDT = 8 And IsDate(iVar(0))))
If cDT Then
iResult(Pc) = DateValue(iVar(0)) + TimeValue(iVar(0))
Else
iResult(Pc) = iVar(3)
End If
Else
vVar = VarType(iVar(0))
If iVar(2) = (vVar = iVar(1)) Then
iResult(Pc) = iVar(3)
Else
iResult(Pc) = iVar(0)
End If
End If
End If
End If
Pc = Pc + 1
Next
End If
VarChk = iResult
End Function
|
0 件のコメント:
コメントを投稿
注: コメントを投稿できるのは、このブログのメンバーだけです。