/build/static/layout/Breadcrumb_cap_w.png

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.


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)

Posted by: WiseUser 19 years ago
Fourth Degree Brown Belt
0
I'm not sure I've understood what you're asking, but if I have the try replacing this line:

WScript.Echo "'" & stritem & "'"

With this line:

WScript.Echo "'" & MsiConfig.Item(strkey) & "'"

Hope this is useful?
Posted by: kkaminsk 19 years ago
9th Degree Black Belt
0
Thanks, that is exactly what I needed to know.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ