Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries



Links

Issociate
Impressum

#1: Detecting Installed Softwares on PC

Posted on 2005-10-04 13:47:31 by Sandeep Deshpande

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 =91Add/Remove Programs=92 op=
tions
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 for=
mat
I want.

I would appreciate all kinds of suggestions/hints/clues/guidance regardin=
g
this requirement.

Thanks & Regards,
Sandeep Deshpande


_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Report this message

Mr Ad

Google

#2: RE: Detecting Installed Softwares on PC

Posted on 2005-10-04 14:28:24 by dave

> -----Original Message-----
> From: Sandeep Deshpande [mailto:deshpandes@kwglobal.com]
> Sent: 04 October 2005 12:48
> To: activeperl@listserv.ActiveState.com
> 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
> ActivePerl@listserv.ActiveState.com
> 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
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Report this message

#3: Re: Detecting Installed Softwares on PC

Posted on 2005-10-04 23:34:40 by Nahum Cohen

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\\Window s\\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\\Window s\\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 <Dave@royalfree.nhs.uk> wrote:
>
>
> > -----Original Message-----
> > From: Sandeep Deshpande [mailto:deshpandes@kwglobal.com]
> > Sent: 04 October 2005 12:48
> > To: activeperl@listserv.ActiveState.com
> > 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
> > ActivePerl@listserv.ActiveState.com
> > 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
> ActivePerl@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Report this message

#4: RE: Detecting Installed Softwares on PC

Posted on 2005-10-05 09:25:15 by Sandeep Deshpande

Dear Mr. Cohen and Mr. Dave,
I thank both you for providing great solutions. I will surely explore these
scripts.

Thanks & Regards,
Sandeep Deshpande

-----Original Message-----
From: Nahum Cohen [mailto:nahum.cohen@gmail.com]
Sent: Wednesday, October 05, 2005 3:05 AM
To: Ramlakhan, Dave
Cc: deshpandes@kwglobal.com; activeperl@listserv.activestate.com
Subject: Re: Detecting Installed Softwares on PC

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\\Window s\\CurrentVersio
n\\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\\Window s\\CurrentVersio
n\\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 <Dave@royalfree.nhs.uk> wrote:
>
>
> > -----Original Message-----
> > From: Sandeep Deshpande [mailto:deshpandes@kwglobal.com]
> > Sent: 04 October 2005 12:48
> > To: activeperl@listserv.ActiveState.com
> > 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
> > ActivePerl@listserv.ActiveState.com
> > 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
> ActivePerl@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Report this message