I am trying to pull a list of installed software on a remote server. I
chose not to use the Win32_Product Class since this only returns software
that was installed using Windows Installer.
Instead, I chose to enumerate all of the sub-keys under
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" and peform a
GetStringValue for the "DisplayName" value.

The Process Flow is as follows:
      1. Enumerate all the sub-keys under
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"
      2. Store these sub-keys in an array
      3. Loop through the array of sub-keys
      4. Perform a GetStringValue on the value "DisplayName" using the path
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\$sub-key"


Here is a description of my issue:
      I have been able to enumerate the sub-keys successfully however I can
not get the value of "DisplayName" for each sub-key.

Here are my findings:
      I think I have narrowed down the issue to the RegPath parameter that
I am passing to the method "GetStringValue".
      If I dynamically specify the RegPath by passing a scalar which holds
the path, it seems that the string value is not returned.
      However if I provide a static path in the method parameters such as
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Winzip" then the
correct DisplayName is  returned.


Can anyone recommend a solution to this issue that I am having?
Or can anyone recommend a better solution?
P.S. I would like to use the Win32::OLE module since I want to limit the
number of modules incorporated into the script since it may run on machines
that do not have certain modules installed.

Thank You!




Please review my source code below:


use Win32::OLE('in');
use Win32::OLE::Variant;
use constant HKEY_LOCAL_MACHINE => 0x80000002;

  $WMIreg =
Win32::OLE->GetObject("winmgmts:\\\\$Computer\\root\\default:StdRegProv");
  $KeyPath = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\";
  $Subkeys = Variant(VT_ARRAY | VT_VARIANT | VT_BYREF, [1,1]);
  $WMIreg->EnumKey(HKEY_LOCAL_MACHINE, $KeyPath, $Subkeys);
  @Keys;
  foreach $Key(in($Subkeys->Value))
  {
    push(@Keys, $Key);
  }

  foreach $Key(@Keys)
  {
    #$NewKeyPath =
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\$Key";
    $NewKeyPath =
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Winzip";
    $ValueName = "DisplayName";
    $DisplayName = Variant(VT_BSTR | VT_BYREF, "");
    print "$NewKeyPath\n";
    $WMIreg->GetStringValue(HKEY_LOCAL_MACHINE, $NewKeyPath, $ValueName,
$DisplayName);
    print "$DisplayName\n";
  }



*******************************************************************

This email and any files transmitted with it are confidential 
and intended solely for the use of the individual or entity 
to whom they are addressed. If you have received this 
email in error please notify the sender by replying to this 
email and then delete it from your system.

No reliance may be placed upon this email without written
confirmation of its contents and any liability arising from 
such reliance without written confirmation is hereby 
excluded.

JRI America

*******************************************************************

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to