This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Insert Record to IniFile
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 11, 2008
03:58 PM
Insert Record to IniFile
Howdy,
Would appreciate a nudge in the right direction here:
Using InstallShield 2008 Pro and have a legacy install that writes an INI file with a reference to the CD Rom drive letter and folder. I need to install this software where the possibility of the CD Rom having a different drive letter is possible.
Searched and found the vbs code to find the drive letter:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_CDROMDrive")
dim myVariableName
For Each objItem in colItems
myVariableName = objItem.Drive & "\grade4\"
Next
I've added the "\grade4\" because that's a folder on the CD that has the data the program uses.
I've looked into inserting a record into the IniFile table and have come up with the following:
Dim MsiDb
Dim MsiInstall
Dim MsiRecord
Dim MsiView
Set MsiDb = Session.Database
Set MsiInstall = Session.Installer
Set MsiView = MsiDb.OpenView("SELECT * FROM IniFile")
Set MsiRecord = MsiInstall.CreateRecord(8)
MsiRecord.StringData(2) = "WELCOME.INI"
MsiRecord.StringData(3) = "INSTALLDIR"
MsiRecord.StringData(4) = "Environment"
MsiRecord.StringData(5) = "DefaultPath"
MsiRecord.StringData(6) = myVariableName"
MsiRecord.StringData(7) = "1
MsiRecord.StringData(8) = "IniFileEntries"
Call MsiView.Execute(MsiRecord)
Call MsiView.Modify (4, MsiRecord)
Call MsiView.Close
Checking the install log after an attempted install, I get an error for my Custom Action pointing to Call MsiView.Modify (7, MsiRecord). I've read a little where the number depends on the type of table being used. A table with a key file can only be modified a certain way. As seen above, I don't populate MsiRecord.StringData(1) because when you insert a record by hand, IniFile table, the IniFile column (key) is autoinserted.
I've tried the CA in different modes (immediate, deferred, commit) as well with no success.
Any help would be greatly appreciated!
Thanks,
Arnold Moreno
NISD - NEDSS
Would appreciate a nudge in the right direction here:
Using InstallShield 2008 Pro and have a legacy install that writes an INI file with a reference to the CD Rom drive letter and folder. I need to install this software where the possibility of the CD Rom having a different drive letter is possible.
Searched and found the vbs code to find the drive letter:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_CDROMDrive")
dim myVariableName
For Each objItem in colItems
myVariableName = objItem.Drive & "\grade4\"
Next
I've added the "\grade4\" because that's a folder on the CD that has the data the program uses.
I've looked into inserting a record into the IniFile table and have come up with the following:
Dim MsiDb
Dim MsiInstall
Dim MsiRecord
Dim MsiView
Set MsiDb = Session.Database
Set MsiInstall = Session.Installer
Set MsiView = MsiDb.OpenView("SELECT * FROM IniFile")
Set MsiRecord = MsiInstall.CreateRecord(8)
MsiRecord.StringData(2) = "WELCOME.INI"
MsiRecord.StringData(3) = "INSTALLDIR"
MsiRecord.StringData(4) = "Environment"
MsiRecord.StringData(5) = "DefaultPath"
MsiRecord.StringData(6) = myVariableName"
MsiRecord.StringData(7) = "1
MsiRecord.StringData(8) = "IniFileEntries"
Call MsiView.Execute(MsiRecord)
Call MsiView.Modify (4, MsiRecord)
Call MsiView.Close
Checking the install log after an attempted install, I get an error for my Custom Action pointing to Call MsiView.Modify (7, MsiRecord). I've read a little where the number depends on the type of table being used. A table with a key file can only be modified a certain way. As seen above, I don't populate MsiRecord.StringData(1) because when you insert a record by hand, IniFile table, the IniFile column (key) is autoinserted.
I've tried the CA in different modes (immediate, deferred, commit) as well with no success.
Any help would be greatly appreciated!
Thanks,
Arnold Moreno
NISD - NEDSS
(2) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 11, 2008
05:47 PM
Instead of modifying the in-memory IniFile table, perhaps create a normal INI entry but use a property ([CD_DRIVE_LETTER]) as the INI data; and then use a custom action to set the property value? With InstallScript, for example, there's a GetValidDrivesList function that can help.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 13, 2008
01:46 PM
Thanks for your help, Robert!
Used Installscript's GetValidDrivesList and did a little extra reading up to properly use MsiSetProperty and voila! Success!!
Appreciate your help.
- Arnold
Used Installscript's GetValidDrivesList and did a little extra reading up to properly use MsiSetProperty and voila! Success!!
Appreciate your help.
- Arnold
![](/skins/images/A5EADE085F77DE82FB3B14D6B307AE6A/responsive_peak/images/icon_anonymous_message.png)