Const ForReading = 1
Const ForWriting = 2
Const TristateTrue = -1
strFolder = "c:\files"
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colSubfolders = objWMIService.ExecQuery _
("Associators of {Win32_Directory.Name='" & strFolder & "'} " _
& "Where AssocClass = Win32_Subdirectory " _
& "ResultRole = PartComponent")
For Each objSubfolder in colSubfolders
strFile1 = strFolder & "\" & objSubfolder.FileName & "\cpInstall.ini"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(strFile1, ForReading)
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
intLineFinder = InStr(strNextLine, "Desc=")
If intLineFinder <> 0 Then
strNextLine = "Desc=#" & objSubfolder.FileName
End If
intLineFinder = InStr(strNextLine, "Branch=")
If intLineFinder <> 0 Then
strNextLine = "Branch=" & objSubfolder.FileName
End If
strNewFile = strNewFile & strNextLine & vbCrLf
Loop
objTextFile.Close
Set objTextFile = objFSO.OpenTextFile(strFile1, ForWriting)
objTextFile.WriteLine strNewFile
objTextFile.Close
strNewFile = ""
strFile2 = strFolder & "\" & objSubfolder.FileName & "\sal_cp.reg"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(strFile2, ForReading, False, TristateTrue)
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
intLineFinder = InStr(strNextLine, Chr(34) & "StoreNumber" & Chr(34) & "=")
If intLineFinder <> 0 Then
strNextLine = Chr(34) & "StoreNumber" & Chr(34) & "=dword:" & Hex(objSubfolder.FileName)
End If
strNewFile = strNewFile & strNextLine & vbCrLf
Loop
objTextFile.Close
Set objTextFile = objFSO.OpenTextFile(strFile2, ForWriting, False, TristateTrue)
objTextFile.WriteLine strNewFile
objTextFile.Close
strNewFile = ""
Next
|