Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Modyfing Registry via VBScript


2 replies to this topic

VriesW

VriesW
  • Members
  • 2 posts

Posted 07 February 2003 - 09:55

I'm trying to modify an multi-string value (replace one substring with an other) using a Custom Action VBScript from installation). The code I'm using:

Set objRegistry = GetObject("winmgmts:root\default:StdRegProv")
....
Case REG_MULTI_SZ
           intRC = objRegistry.SetMultiStringValue(intRegRoot, strKeyPad, strValNaam, Split(strValWaarde, ARR_SCHEID_TEKEN))
....

It works fine when I run the script from the command line. However, when running it from installation nothing happens. I also tried to call a Delphi executable that I wrote, which does the same. Also nothing happens. Can someone explain why this doesn't work?

Kind regards W. de Vries

colby

colby
  • Full Members
  • 37 posts

Posted 07 February 2003 - 19:42

First of all, no I can't explain it.  I'm having considerable trouble myself.  But perhaps I can offer a hypothesis?

I think invoking VBScript from the Windows Installer session executes the script only within the context of the Windows Installer session.  

I think to do what you're trying to do, you would have to add the registry key/value you're trying to set to the Registry Table of the installation package and then minipulate the value using the Installer or Session objects properties and methods to retrieve the current value and replace it with the new value.  Of course, then you have to figure out at what sequence to execute the CA.  I would think this would be prior to WriteRegistryValues standard action.

VriesW

VriesW
  • Members
  • 2 posts

Posted 12 February 2003 - 15:32

Hello,

The error wasn't the creation of a StdRegProv object reference. In my code I used the method EnumValues(rootkey, subkey, names, types). After executing this method, the third and fourth parameter contain the names and types respectively under the subkey (2nd parameter). The code that I used was:

Dim arrNames(), arrTypes()

...
intRc = objRegistry(HKEY_CURRENT_USER, "ASubKey", arrNames, arrTypes)
...

Executing the script from the command line worked. To execute this code from Wise remove the array characters "()":

Dim arrNames, arrTypes

...
intRc = objRegistry(HKEY_CURRENT_USER, "ASubKey", arrNames, arrTypes)
...

Kind regards, W. de Vries