Do I know how to use a dictionary or am I on the wong path?
I got some mess of a code which definately is a work in progress but here is the code.
So if we look at the following code stritem is blank. Can anybody tell me why?
Dim oldzensourcepath
Dim zensourcepath
Dim Shell
Dim FSO
Dim ErrorSource
Dim Key
Dim Code
Rem Set up the WshShell object
Set Shell = CreateObject("wscript.shell")
Set FSO = CreateObject("Scripting.FileSystemObject")
oldzensourcepath = "\\cnrlfs05\vol10\ZENWORKS\Win2k"
On Error Resume Next
Rem Set the application name for error reporting purposes.
ErrorSource = "ZENSOURCEPATH MSI Change Utilitiy"
Key = "HKLM\Software\CNRL\" & Errorsource
Code = "0"
If err.number <> 0 Then
Shell.RegWrite Key & "\Code", err.number
Shell.RegWrite Key & "\Error Message", err.description
Quit
End If
CheckFilePath
Sub CheckFilePath
On Error Resume Next
If FSO.FileExists("c:\temp\zensp.txt") Then
READFILE
Else
Err.raise "6029", ErrorSource, "ZENSOURCEPATH File not Found!"
Shell.RegWrite Key & "\Code", err.number
Shell.RegWrite Key & "\Error Message", err.description
Quit
End If
End Sub
Sub READFILE
On Error Resume Next
Dim fso, f1, ts, zensourcepath
Set fso = CreateObject("Scripting.FileSystemObject")
Const ForReading = 1
' Read the contents of the file.
WScript.Echo "Reading file <br>"
Set ts = fso.OpenTextFile("c:\temp\zensp.txt", ForReading)
zensourcepath = ts.ReadLine
WScript.Echo "File contents = '" & zensourcepath & "'"
ts.Close
If err.number <> 0 Then
Shell.RegWrite Key & "\Code", err.number
Shell.RegWrite Key & "\Error Message", err.description
Quit
End If
WScript.Echo "File contents = '" & zensourcepath & "'"
Set msiObject = WScript.CreateObject("WindowsInstaller.Installer")
Set MsiConfig = WScript.CreateObject("Scripting.Dictionary")
MsiConfig.Add "{505AFDC0-5E72-4928-8368-5DEA385E3647}", zensourcepath & "\CorelDRAW 12\"
MSIKeys = MsiConfig.Keys
MSIItems = MsiConfig.Items
For Each strkey In MSIKeys
WScript.Echo strkey
WScript.Echo "'" & stritem & "'"
msiObject.ClearSourceList strkey, ""
msiObject.AddSource strkey, "", stritem
Next
So if we look at the following code stritem is blank. Can anybody tell me why?
WScript.Echo "File contents = '" & zensourcepath & "'"
Set msiObject = WScript.CreateObject("WindowsInstaller.Installer")
Set MsiConfig = WScript.CreateObject("Scripting.Dictionary")
MsiConfig.Add "{505AFDC0-5E72-4928-8368-5DEA385E3647}", zensourcepath & "\CorelDRAW 12\"
MSIKeys = MsiConfig.Keys
MSIItems = MsiConfig.Items
For Each strkey In MSIKeys
WScript.Echo strkey
WScript.Echo "'" & stritem & "'"
msiObject.ClearSourceList strkey, ""
msiObject.AddSource strkey, "", stritem
Next
0 Comments
[ + ] Show comments
Answers (2)
Please log in to answer
Posted by:
WiseUser
19 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.