Option Explicit
Dim IFILE
Dim OFILE
'IFILE = "P_icacls.cmd_out.txt"
' 入力チェック
If WScript.Arguments.Count < 1 Then
WScript.Echo " PARAM ERROR Arguments.Count=" & WScript.Arguments.Count
wscript.Quit(4)
End If
IFILE = WScript.Arguments(0)
OFILE = IFILE & "_out.txt"
Call ACLS(IFILE,OFILE)
wscript.Quit(0)
'************************************************
' ACL結果の整形
'************************************************
Sub ACLS(IFILE,OFILE)
Dim objFSO
Dim objIFILE
Dim objOFILE
Dim iCnt
Dim OCnt
Dim sRec
Dim sPath
Dim sUser
Dim iPos
Set objFSO = CreateObject("Scripting.FileSystemObject")
' 指定ファイルをOPEN
Set objIFILE = objFSO.OpenTextFile(IFILE, 1)
Set objOFILE = objFSO.CreateTextFile(OFILE)
sRec = ""
iCnt = 0
OCnt = 0
iPos = 0
Do Until objIFILE.AtEndOfStream = True
sRec = objIFILE.ReadLine
iCnt = iCnt + 1
If sRec > "" Then
'空白行でない場合
If Mid(sRec,1,1) <> " " Then
'1桁目が空白以外の場合
iPos = InstrRev(sRec," ")
'パスとユーザに分ける
sPath = trim(Mid(sRec,1,ipos - 1))
sUser = trim(Replace(sRec, sPath, ""))
sRec = sPath & vbtab & sUser
Else
'1桁目が空白の場合
sRec = sPath & vbtab & trim(sRec)
End If
objOFILE.WriteLine sRec
OCnt = OCnt + 1
End If
Loop
WScript.Echo IFILE & " -> " & OFILE
WScript.Echo now & " iCnt=" & iCnt & " OCnt=" & OCnt
objOFILE.Close
objIFILE.Close
Set objOFILE = Nothing
Set objIFILE = Nothing
Set objFSO = Nothing
End Sub