Dave,
The sample script that you sent works nicely but have one big
disadvantage: it will return the list of application installed using
Microsoft Windows Installer technology only, which - according to
Microsoft - should be the standard for all applications installations
.
But since we don't live in an ideal MS world, not all applications
installs using MSI technology. As administrator you would like to get
the full picture and not partial.
One way to do it is to parse the relevant registry keys:
----------------- start sample script --------------
use Win32::TieRegistry;
GetInstalledAppList();
for ($i = 0 ; $i <= $#InstalledAppList ; $i++)
{
print $InstalledAppList[$i] . "\n";
}
sub GetInstalledAppList()
{
# read the root registry key where Windows store the information of
all installed applications. We get an array in "non human-readable"
format.
$RootReg =
$Registry->{"HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"};
foreach (keys %$RootReg)
{
push @RootKeys, $_ ;
}
# go over each application key and read the DisplayName (in
add/remove software) value. Applications that does not have this entry
are hidden from the user.
for ($i = 0 ; $i <= $#RootKeys ; $i++)
{
chop $RootKeys[$i];
$ChildReg =
$Registry->{"HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\$RootKeys[$i]\\DisplayName"};
if (! $ChildReg)
{
push @InstalledAppList, "$RootKeys[$i]|hidden";
}
else
{
for ($iLookForDup = 0 ; $iLookForDup <= $i ;
$iLookForDup++)
{
@tmp = split /\|/ ,
$InstalledAppList[$iLookForDup];
if ($tmp[1] eq $ChildReg)
{
$DuplicateFound = 1;
}
}
if (! $DuplicateFound)
{
push @InstalledAppList, "$ChildReg|visible";
}
undef $DuplicateFound;
}
}
# alphabetic soft
@InstalledAppList = sort(@InstalledAppList);
return @InstalledAppList;
}
----------------- end sample script --------------
On 10/4/05, Ramlakhan, Dave <[EMAIL PROTECTED]> wrote:
>
>
> > -----Original Message-----
> > From: Sandeep Deshpande [mailto:[EMAIL PROTECTED]
> > Sent: 04 October 2005 12:48
> > To: [email protected]
> > Subject: Detecting Installed Softwares on PC
> >
> >
> > Dear All,
> > I want to develop a program which would scan a PC and tell
> > what Softwares
> > are installed on the said PC. In Windows the 'Add/Remove
> > Programs' options
> > shows you list of Installed Softwares, I would like perl
> > script to detect
> > those softwares. Once I get the names then I can put them in
> > whatever format
> > I want.
> >
> > I would appreciate all kinds of
> > suggestions/hints/clues/guidance regarding
> > this requirement.
> >
> > Thanks & Regards,
> > Sandeep Deshpande
> >
> >
> > _______________________________________________
> > ActivePerl mailing list
> > [email protected]
> > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> >
>
> I got this using scriptomatic:
>
> *****Begin Code*************
> use Win32::OLE('in');
> use constant wbemFlagReturnImmediately => 0x10;
> use constant wbemFlagForwardOnly => 0x20;
>
> print "first arg is : $ARGV[0]\n";
>
> $computer = $ARGV[0] or ".";
> $objWMIService = Win32::OLE->GetObject
> ("winmgmts:\\\\$computer\\root\\CIMV2") or die "WMI connection
> failed.\n";
> $colItems = $objWMIService->ExecQuery
> ("SELECT * FROM Win32_Product","WQL",wbemFlagReturnImmediately |
> wbemFlagForwardOnly);
>
> foreach my $objItem (in $colItems)
> {
> print "Caption: $objItem->{Caption}\n";
> print "Description: $objItem->{Description}\n";
> print "Identifying Number: $objItem->{IdentifyingNumber}\n";
> print "Install Date: $objItem->{InstallDate}\n";
> print "Install Date 2: $objItem->{InstallDate2}\n";
> print "Install Location: $objItem->{InstallLocation}\n";
> print "Install State: $objItem->{InstallState}\n";
> print "Name: $objItem->{Name}\n";
> print "Package Cache: $objItem->{PackageCache}\n";
> print "SKU Number: $objItem->{SKUNumber}\n";
> print "Vendor: $objItem->{Vendor}\n";
> print "Version: $objItem->{Version}\n";
> print "\n";
> }
> $colItems = $objWMIService->ExecQuery
> ("SELECT * FROM
> Win32_QuickFixEngineering","WQL",wbemFlagReturnImmediately |
> wbemFlagForwardOnly);
>
> foreach my $objItem (in $colItems)
> {
> print "Caption: $objItem->{Caption}\n";
> print "CS Name: $objItem->{CSName}\n";
> print "Description: $objItem->{Description}\n";
> print "Fix Comments: $objItem->{FixComments}\n";
> print "HotFix ID: $objItem->{HotFixID}\n";
> print "Install Date: $objItem->{InstallDate}\n";
> print "Installed By: $objItem->{InstalledBy}\n";
> print "Installed On: $objItem->{InstalledOn}\n";
> print "Name: $objItem->{Name}\n";
> print "Service Pack In Effect: $objItem->{ServicePackInEffect}\n";
> print "Status: $objItem->{Status}\n";
> print "\n";
> }
>
> ****End Code********
> _______________________________________________
> ActivePerl mailing list
> [email protected]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs