Perl Script on x64 Windows

Perl Script on x64 Windows

am 21.12.2005 19:19:20 von anthony.okusanya

Hi all
I have a utility I wrote using ActivePerl. It is used to install applications and hotfixes on Windows servers. I am trying to modify this to work with the 64bit version of Windows 2003. The problem is that due to the registry re-direction that 64it uses to maintain 32bit compatibility, my script is not reading the registry keys properly.
Here is a sample of my script. the CHKPATCH subroutine is used to test for the existence of a patch
e.g to determine if KB896424 is installed I simply call CHKPATCH("KB896424").
On 64bit, this utility does not read the registry key listed below because its running in 32 bit mode
even though I can see the key when I run Regedit from the server.

use Win32::TieRegistry(Delimiter=>"/");
........
sub CHKPATCH
{
my $hotfix;
if($hotfix =$Registry->{"LMachine/SOFTWARE/Microsoft/Windows NT/CurrentVersion/HotFix/$_[0]"})
{
return 1;
}
else
{
return 0;
}

}

Sorry for Rambling on and on but if anyone has any ideas I would be most appreciative

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

Re: Perl Script on x64 Windows

am 21.12.2005 20:31:33 von dbecoll

Anthony Okusanya wrote:

> Hi all
> I have a utility I wrote using ActivePerl. It is used to install applications and hotfixes on Windows servers. I am trying to modify this to work with the 64bit version of Windows 2003. The problem is that due to the registry re-direction that 64it uses to maintain 32bit compatibility, my script is not reading the registry keys properly.
> Here is a sample of my script. the CHKPATCH subroutine is used to test for the existence of a patch
> e.g to determine if KB896424 is installed I simply call CHKPATCH("KB896424").
> On 64bit, this utility does not read the registry key listed below because its running in 32 bit mode
> even though I can see the key when I run Regedit from the server.
>
> use Win32::TieRegistry(Delimiter=>"/");
> .......
> sub CHKPATCH
> {
> my $hotfix;
> if($hotfix =$Registry->{"LMachine/SOFTWARE/Microsoft/Windows NT/CurrentVersion/HotFix/$_[0]"})
> {
> return 1;
> }
> else
> {
> return 0;
> }
>
> }
>
> Sorry for Rambling on and on but if anyone has any ideas I would be most appreciative

If you read the keys around that area, which ones work and which don't ?
Like can you access the HotFix key above $_[0] ? If you can see it in regedit,
you would think you could see if from Perl.

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

RE: Perl Script on x64 Windows

am 21.12.2005 21:14:50 von Jan Dubois

On Wed, 21 Dec 2005, $Bill Luebkert wrote:
> If you read the keys around that area, which ones work and which don't?
> Like can you access the HotFix key above $_[0] ? If you can see it
> in regedit, you would think you could see if from Perl.

Nope, 32 bit application on Win64 run in an environment called WOW64 (Windows
on Windows 64). In this environment various parts of the file system and
registry are remapped. This means that some parts of the system are
inaccessible to 32 bit applications. Just because you can see it in regedit
doesn't mean that 32 bit Perl will see it too.

Cheers,
-Jan


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

RE: Perl Script on x64 Windows

am 21.12.2005 21:29:58 von Jan Dubois

On Wed, 21 Dec 2005, Anthony Okusanya wrote:
> Hi all I have a utility I wrote using ActivePerl. It is used to
> install applications and hotfixes on Windows servers. I am trying to
> modify this to work with the 64bit version of Windows 2003. The
> problem is that due to the registry re-direction that 64it uses to
> maintain 32bit compatibility, my script is not reading the registry
> keys properly.

You could try working around the registry redirection by using Windows
Scripting Host. I haven't tried this, but it is likely that those will
be 64 bit components and run outside the WOW64 subsystem.

Here is some minimal sample to read a value (use some other key, as the
default value for "HotFix" is normally not set):

use Win32::OLE;
my $shell = Win32::OLE->new("WScript.Shell");
print $shell->RegRead('HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\HotFix\\');

You do have to use backslashes in the keyname. Run with `perl -w` to get
all error messages if something goes wrong.

Here is a link to the RegRead() documentation:

http://msdn.microsoft.com/library/default.asp?url=/library/e n-us/script56/html/af4423b2-4ee8-41d6-a704-49926cd4d2e8.asp

Please report back if this works around the problem or not.

Cheers,
-Jan



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

Re: Perl Script on x64 Windows

am 21.12.2005 21:46:03 von dbecoll

Jan Dubois wrote:

> On Wed, 21 Dec 2005, $Bill Luebkert wrote:
>
>>If you read the keys around that area, which ones work and which don't?
>>Like can you access the HotFix key above $_[0] ? If you can see it
>>in regedit, you would think you could see if from Perl.
>
>
> Nope, 32 bit application on Win64 run in an environment called WOW64 (Windows
> on Windows 64). In this environment various parts of the file system and
> registry are remapped. This means that some parts of the system are
> inaccessible to 32 bit applications. Just because you can see it in regedit
> doesn't mean that 32 bit Perl will see it too.

There's gotta be a way to get around it - just a matter of finding the
easiest way. ;)
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Re: Perl Script on x64 Windows

am 21.12.2005 21:57:59 von rvtol+news

Anthony Okusanya:

> if($hotfix =$Registry->{"LMachine/.../$_[0]"}) {


Try a simple test.pl that contains only something like this:

#!/usr/bin/perl

use strict; use warnings;

use Win32::TieRegistry(Delimiter => '/');

my $regkey = 'LMachine/SOFTWARE/Microsoft/Windows NT/'
. 'CurrentVersion/HotFix/' . $_[0] . '/';

my $hotfix = $Registry->{$regkey}
or die "Can't read registry key $regkey $^E\n";

print 'Comments:', $hotfix->{'Comments'}, "\n";
print '/Comments:', $hotfix->{'/Comments'}, "\n";

and work on from that.

--
Affijn, Ruud

"Gewoon is een tijger."

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

Re: Perl Script on x64 Windows

am 21.12.2005 22:11:38 von eric-amick

> Hi all
> I have a utility I wrote using ActivePerl. It is used to install
> applications and hotfixes on Windows servers. I am trying to modify this to work
> with the 64bit version of Windows 2003. The problem is that due to the registry
> re-direction that 64it uses to maintain 32bit compatibility, my script is not
> reading the registry keys properly.
> Here is a sample of my script. the CHKPATCH subroutine is used to test for the
> existence of a patch
> e.g to determine if KB896424 is installed I simply call CHKPATCH("KB896424").
> On 64bit, this utility does not read the registry key listed below because its
> running in 32 bit mode
> even though I can see the key when I run Regedit from the server.
>
> use Win32::TieRegistry(Delimiter=>"/");
> .......
> sub CHKPATCH
> {
> my $hotfix;
> if($hotfix =$Registry->{"LMachine/SOFTWARE/Microsoft/Windows
> NT/CurrentVersion/HotFix/$_[0]"})
> {
> return 1;
> }
> else
> {
> return 0;
> }
>
> }
>
> Sorry for Rambling on and on but if anyone has any ideas I would be most
> appreciative

What you're looking for is a key, so you need a trailing slash:

$Registry->{"LMachine/SOFTWARE/Microsoft/Windows
NT/CurrentVersion/HotFix/$_[0]/"}

I'm frankly surprised it ever worked.

--
Eric Amick
Columbia, MD

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

Re: Perl Script on x64 Windows

am 21.12.2005 23:01:17 von rvtol+news

Anthony Okusanya schreef:

> I have a utility I wrote using ActivePerl. It is used to
> install applications and hotfixes on Windows servers. I am trying to
> modify this to work with the 64bit version of Windows 2003. The
> problem is that due to the registry re-direction that 64it uses to
> maintain 32bit compatibility, my script is not reading the registry
> keys properly.

http://support.microsoft.com/default.aspx?scid=kb;EN-US;3050 97
In the 64-bit version of Registry Editor, 32-bit keys are displayed
under the following registry key:
HKEY_LOCAL_MACHINE\Software\WOW6432Node

Alternatively, have you looked into Remote Registry Access? \\127.0.0.1

--
Affijn, Ruud

"Gewoon is een tijger."


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

Re: Perl Script on x64 Windows

am 21.12.2005 23:20:30 von rvtol+news

Eric Amick schreef:

> [Windows Registry query]
> What you're looking for is a key, so you need a trailing slash:
> [...]
> I'm frankly surprised it ever worked.


http://search.cpan.org/~jdb/libwin32-0.26/TieRegistry/TieReg istry.pm
"If you are reading from the hash [fetching], then we first use the key
string as a value name. If there is a value with a matching name in the
Registry key which the hash is tied to, then the value data string [and
possibly the value data type] is returned. Otherwise, we retry by using
the hash key string as a subkey name. If there is a subkey with a
matching name, then we return a reference to a hash tied to that subkey.
Otherwise we return undef."

But also:
"matching subkey names that contain the user-selected delimiter only
works if case is matched"
so maybe 'SOFTWARE' should be 'Software'.

--
Affijn, Ruud

"Gewoon is een tijger."


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

Re: Perl Script on x64 Windows

am 21.12.2005 23:25:46 von dbecoll

Jan Dubois wrote:

> On Wed, 21 Dec 2005, Anthony Okusanya wrote:
>
>>Hi all I have a utility I wrote using ActivePerl. It is used to
>>install applications and hotfixes on Windows servers. I am trying to
>>modify this to work with the 64bit version of Windows 2003. The
>>problem is that due to the registry re-direction that 64it uses to
>>maintain 32bit compatibility, my script is not reading the registry
>>keys properly.
>
>
> You could try working around the registry redirection by using Windows
> Scripting Host. I haven't tried this, but it is likely that those will
> be 64 bit components and run outside the WOW64 subsystem.
>
> Here is some minimal sample to read a value (use some other key, as the
> default value for "HotFix" is normally not set):
>
> use Win32::OLE;
> my $shell = Win32::OLE->new("WScript.Shell");
> print $shell->RegRead('HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\HotFix\\');

This works for 32 bit:

use Win32::OLE;
my $shell = Win32::OLE->new("WScript.Shell");
my $ret = $shell->RegRead("HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\KB896424\\Installed") or warn "RegRead: " . Win32::OLE->LastError();
print "$ret\n";

Wouldn't work until I took it down to the Installed subkey.

> You do have to use backslashes in the keyname. Run with `perl -w` to get
> all error messages if something goes wrong.
>
> Here is a link to the RegRead() documentation:
>
> http://msdn.microsoft.com/library/default.asp?url=/library/e n-us/script56/html/af4423b2-4ee8-41d6-a704-49926cd4d2e8.asp
>
> Please report back if this works around the problem or not.
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Best module for sending e-mail?

am 27.12.2005 19:33:48 von oakb

Hi all,

I need to send automated e-mail reports from Windows boxes, with no
sendmail or other MTA available. I've tried several modules so far
and, although I've been able to mostly make them work, none of them
has satisfied all of my requirements -- much less my admittedly
idealistic wishes. Please reply if you know of a module that might
become my new bee's knees of e-mail sending-ness. :D

Here's my requirement list:

>> Must stand alone, not rely on any MTA on localhost

>> Must be configurable for SMTP server and port

>> Must be SMTP AUTH capable

>> Must auto-negotiate TLS when it's available

>> Must be able to use SSL when so configured

>> Must work well when rolled into an AS PerlApp .exe


As for my aforementioned idealistic wishes, I would like the module to
be fairly high-level (if I really wanted to, I could roll my own with
Net::SMTP, etc.) and easy to implement; it would be great if the
module was nice and compact; and a well-done OO interface is almost a
requirement.

Thanks,

-Brian

_________________________
Brian H. Oak CISSP CISA
Acorn Networks & Security


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

RE: Best module for sending e-mail?

am 27.12.2005 20:03:09 von robert.l.hicks

> Here's my requirement list:
>
> >> Must stand alone, not rely on any MTA on localhost
>
> >> Must be configurable for SMTP server and port
>
> >> Must be SMTP AUTH capable
>
> >> Must auto-negotiate TLS when it's available
>
> >> Must be able to use SSL when so configured
>
> >> Must work well when rolled into an AS PerlApp .exe
>

I use Mail::Sender but you will have to check it against your list.

Robert

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

RE: Best module for sending e-mail?

am 27.12.2005 22:13:27 von oakb

Robert,

Thanks for the suggestion, but Mail::Sender fails pretty soon down the
list of requirements: Mail::Sender can only send mail to a server on
port 25/TCP. As far as I can tell, Mail::Sender only fulfills the
first item on the requirements list. These are exactly the kinds of
shortcomings that have forced me to continue looking for a better
solution.

Cheers,

-Brian

_________________________
Brian H. Oak CISSP CISA
Acorn Networks & Security



-----Original Message-----
From: activeperl-bounces@listserv.ActiveState.com
[mailto:activeperl-bounces@listserv.ActiveState.com] On Behalf Of
Hicks, Robert
Sent: Tuesday, December 27, 2005 12:03
To: activeperl@listserv.ActiveState.com
Subject: RE: Best module for sending e-mail?

> Here's my requirement list:
>
> >> Must stand alone, not rely on any MTA on localhost
>
> >> Must be configurable for SMTP server and port
>
> >> Must be SMTP AUTH capable
>
> >> Must auto-negotiate TLS when it's available
>
> >> Must be able to use SSL when so configured
>
> >> Must work well when rolled into an AS PerlApp .exe
>

I use Mail::Sender but you will have to check it against your list.

Robert

_______________________________________________
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

Re: Best module for sending e-mail?

am 27.12.2005 23:10:38 von DZ-Jay

On Dec 27, 2005, at 16:13, Brian H. Oak wrote:

>
> Thanks for the suggestion, but Mail::Sender fails pretty soon down the
> list of requirements: Mail::Sender can only send mail to a server on
> port 25/TCP. As far as I can tell, Mail::Sender only fulfills the
> first item on the requirements list. These are exactly the kinds of
> shortcomings that have forced me to continue looking for a better
> solution.

Mail::Sender inherits from IO::Socket, and so it exposes its
properties, one of which being the 'port'. For more information check
the IO::Socket info page.

dZ.

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

Re: Best module for sending e-mail?

am 28.12.2005 00:30:34 von Octavian Rasnita

From: "Brian H. Oak"


> Robert,
>
> Thanks for the suggestion, but Mail::Sender fails pretty soon down the
> list of requirements: Mail::Sender can only send mail to a server on
> port 25/TCP. As far as I can tell, Mail::Sender only fulfills the
> first item on the requirements list. These are exactly the kinds of
> shortcomings that have forced me to continue looking for a better
> solution.
>
> Cheers,

For sending mail, you need to have access to an SMTP mail server or to use
an MTA like sendmail.
The perl modules just communicate with the server or the MTA.

Do you have access to an SMTP server? Locally, or from another location,
doesn't matter....

If you don't, then you could use one of the perl modules for sending mail
and using sendmail. If you are running under Windows, I remember that there
are some programs like sendmail for Windows also, or you can install a web
server for Windows.

I hope I have understood correctly what you want.

Teddy

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

RE: Best module for sending e-mail?

am 28.12.2005 15:57:00 von robert.l.hicks

http://search.cpan.org/~cwest/Email-Send-2.00/lib/Email/Send /SMTP.pm

This one lets you set the port and whether SSL is used. I am just
searching on CPAN and there are a few mailers.

Search words: Mail, Email, SMTP

It might be nice to use something like Mail::Sender and mod it to do
what you want and send Jenda a patch so that it will have that
functionality going forward.

Robert

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

RE: Best module for sending e-mail?

am 28.12.2005 16:54:11 von Bowie Bailey

Hicks, Robert wrote:
> http://search.cpan.org/~cwest/Email-Send-2.00/lib/Email/Send /SMTP.pm
>
> This one lets you set the port and whether SSL is used. I am just
> searching on CPAN and there are a few mailers.
>
> Search words: Mail, Email, SMTP
>
> It might be nice to use something like Mail::Sender and mod it to do
> what you want and send Jenda a patch so that it will have that
> functionality going forward.

Are any of these other modules faster than Net::SMTP?

I was writing a Perl program that was sending a lot of mail. I did some
performance testing and found that (on Linux), it was faster to shell
out and call sendmail than to use Net::SMTP.

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

Re: Best module for sending e-mail?

am 29.12.2005 03:34:12 von Foo Ji-Haw

>
>Are any of these other modules faster than Net::SMTP?
>
>I was writing a Perl program that was sending a lot of mail. I did some
>performance testing and found that (on Linux), it was faster to shell
>out and call sendmail than to use Net::SMTP.
>
>
>
If I understand Net::SMTP right, it actually does 2 modes of mail
delivery: sendmail and SMTP. If you have sendmail, you may want to try
the former.
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Re: Best module for sending e-mail?

am 29.12.2005 09:35:32 von Octavian Rasnita

Can anyone explain what's the difference between using sendmail and an SMTP
server?

I am not an expert in MTAs but I think the SMTP server puts the messages in
a queue and try to send them following some rules, while sendmail tries to
send them immediately.
SMTP can be configured to try sending the message the first time
immediately, or only after a certain time, and it can also be configured to
make the next tries at certain specified intervals.

I don't know how sendmail works and what happends if it doesn't succeed
sending the message on its first trial.

So, does anyone know how they work? I am asking this because I have seen
some recommendations of using SMTP it is available and some others saying
that sendmail should be used if it is available.

Teddy

----- Original Message -----
From: "Foo Ji-Haw"
To: "Bowie Bailey"
Cc:
Sent: Thursday, December 29, 2005 04:34 AM
Subject: Re: Best module for sending e-mail?


>
> >
> >Are any of these other modules faster than Net::SMTP?
> >
> >I was writing a Perl program that was sending a lot of mail. I did some
> >performance testing and found that (on Linux), it was faster to shell
> >out and call sendmail than to use Net::SMTP.
> >
> >
> >
> If I understand Net::SMTP right, it actually does 2 modes of mail
> delivery: sendmail and SMTP. If you have sendmail, you may want to try
> the former.
> _______________________________________________
> ActivePerl mailing list

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

Re: Best module for sending e-mail?

am 29.12.2005 10:40:34 von dbecoll

Octavian Rasnita wrote:

> Can anyone explain what's the difference between using sendmail and an SMTP
> server?
>
> I am not an expert in MTAs but I think the SMTP server puts the messages in
> a queue and try to send them following some rules, while sendmail tries to
> send them immediately.
> SMTP can be configured to try sending the message the first time
> immediately, or only after a certain time, and it can also be configured to
> make the next tries at certain specified intervals.
>
> I don't know how sendmail works and what happends if it doesn't succeed
> sending the message on its first trial.
>
> So, does anyone know how they work? I am asking this because I have seen
> some recommendations of using SMTP it is available and some others saying
> that sendmail should be used if it is available.

sendmail is the UNIX method of sending email.

You can read all about it here: http://www.sendmail.org/

Net::SMTP is normally just going to relay your outgoing email to
the specified SMTP host (your ISP's mail server) for delivery.

sendmail is a bit more complicated and not apropos to Windoze
(although there are sendmail look-alikes for Windoze), but does
the same basic job. I'm not sure of the intricacies of sendmail,
you can try to extract them from the website above.


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

Re: Best module for sending e-mail?

am 29.12.2005 11:19:35 von rvtol+news

Octavian Rasnita schreef:

> Can anyone explain what's the difference between using sendmail and
> an SMTP server?

First: please don't top-post.
Second: this group is about Perl.

On a UNIX type system, sendmail is often the software that handles SMTP.
So there is no such difference.

Maybe you mean the difference between requesting a local SMTP-service to
do "it" for you, and doing "it" yourself. The "it" is the transport of
the message to the SMTP-servers near the intended recipients.

--
Affijn, Ruud

"Gewoon is een tijger."


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

RE: Best module for sending e-mail?

am 29.12.2005 14:54:11 von Bowie Bailey

Petr Vileta wrote:
> From: "Bowie Bailey"
> > Are any of these other modules faster than Net::SMTP?
> >
> > I was writing a Perl program that was sending a lot of mail. I did
> > some performance testing and found that (on Linux), it was faster
> > to shell out and call sendmail than to use Net::SMTP.
>
> This is normal :-)
> Net::SMTP comunicate with SMTP server via TCP/IP protocol and must
> 1) open communication
> 2) transfer header and data
> 3) wait for accepting
>
> but using local sendmail use not TCP/IP. Mail header and body from
> your script sendmail get as a standard file (or pipe). Senmail accept
> (or not) this mail, store it into output queue and wait for another.
> After your script commit eg. 1000 mails to sendmail and done, senmail
> continue to work and sending mails from output queue to recipients.

Yes, but it was a bit surprising to find that the overhead for opening
an SMTP connection from Perl is greater than the overhead of spawning a
new process to run sendmail. Before I did the testing, I always used
the Perl module because I assumed that sending mail from within the
program would be more efficient than spawning a process.

I'm not even dealing with sending multiple emails.

I'm comparing this:
my $smtp = Net::SMTP->new('localhost');
$smtp->mail($from);
$smtp->to($to);
$smtp->data();
$smtp->datasend($message);
$smtp->dataend();
$smtp->quit;

To this:
open MAIL, "|sendmail -f $from $to";
print MAIL $message;
close MAIL;

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

Re: RE: Best module for sending e-mail?

am 29.12.2005 17:16:00 von Petr Vileta

> I'm comparing this:
> my $smtp = Net::SMTP->new('localhost');
> $smtp->mail($from);
> $smtp->to($to);
> $smtp->data();
> $smtp->datasend($message);
> $smtp->dataend();
> $smtp->quit;
>
> To this:
> open MAIL, "|sendmail -f $from $to";
> print MAIL $message;
> close MAIL;
>
> --
> Bowie
>
I'm using both form of program. Net::SMTP I'm using if I don't know if user
have sendmail or if I want to send more mails in short time of running
script.
But for using sendmail I use this

$mailprog = '/usr/sbin/sendmail';
open(MAIL,"|$mailprog -t");
print MAIL "From: \"$from_name\" <$from_addr>\n";
print MAIL "Reply-To: $from_addr\n";
print MAIL "To: \"$to_name\" <$to_addr>\n";
print MAIL "Subject: $subj\n";
print MAIL "MIME-Version: 1\.0\n";
print MAIL "Content-Type: text\/plain\; charset\=ISO\-8859\-2\n";
print MAIL "Content-Transfer-Encoding: 8bit\n\n";
print MAIL win2iso($message),"\n\n";
close MAIL;

Petr Vileta, Czech republic
(My server reject all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)


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

Re: Perl Script on x64 Windows

am 04.01.2006 19:08:22 von anthony.okusanya

This is a multipart message in MIME format.
--===============1026005978==
Content-Type: multipart/alternative;
boundary="=_alternative 0063A4CB862570EC_="

This is a multipart message in MIME format.
--=_alternative 0063A4CB862570EC_=
Content-Type: text/plain;
charset=us-ascii
Content-Transfer-Encoding: 7bit

Bill Luebkert Wrote



"$Bill Luebkert"
12/21/2005 04:25 PM

To
"'Anthony Okusanya'"
cc
activeperl@listserv.ActiveState.com
Subject
Re: Perl Script on x64 Windows






Jan Dubois wrote:

> On Wed, 21 Dec 2005, Anthony Okusanya wrote:
>
>>Hi all I have a utility I wrote using ActivePerl. It is used to
>>install applications and hotfixes on Windows servers. I am trying to
>>modify this to work with the 64bit version of Windows 2003. The
>>problem is that due to the registry re-direction that 64it uses to
>>maintain 32bit compatibility, my script is not reading the registry
>>keys properly.
>
>
> You could try working around the registry redirection by using Windows
> Scripting Host. I haven't tried this, but it is likely that those will
> be 64 bit components and run outside the WOW64 subsystem.
>
> Here is some minimal sample to read a value (use some other key, as the
> default value for "HotFix" is normally not set):
>
> use Win32::OLE;
> my $shell = Win32::OLE->new("WScript.Shell");
> print $shell->RegRead('HKLM\\SOFTWARE\\Microsoft\\Windows
NT\\CurrentVersion\\HotFix\\');

This works for 32 bit:

use Win32::OLE;
my $shell = Win32::OLE->new("WScript.Shell");
my $ret = $shell->RegRead("HKLM\\SOFTWARE\\Microsoft\\Windows
NT\\CurrentVersion\\Hotfix\\KB896424\\Installed") or warn "RegRead: " .
Win32::OLE->LastError();
print "$ret\n";

Wouldn't work until I took it down to the Installed subkey.

> You do have to use backslashes in the keyname. Run with `perl -w` to
get
> all error messages if something goes wrong.
>
> Here is a link to the RegRead() documentation:
>
>
http://msdn.microsoft.com/library/default.asp?url=/library/e n-us/script56/html/af4423b2-4ee8-41d6-a704-49926cd4d2e8.asp

>
> Please report back if this works around the problem or not.


I would like to thank everyone for their input on this issue. I appologize
for my late response as I have been trying to
implement most of the suggestions that were sent out on this.

Jan's code sample below produced the same result on the x64bit machine as
it is still being directed to the 32bit registry section
---
use Win32::OLE;
my $shell = Win32::OLE->new("WScript.Shell");
print $shell->RegRead('HKLM\\SOFTWARE\\Microsoft\\Windows
NT\\CurrentVersion\\HotFix\\');
----

I am currently trying to use WMI to make the registry calls however my
code (shown below) does not seem to work.
The VBScript equivalent however does work ( I used Activestates PDK
VBscript converter to generate the perl code)
Can any one help me with this WMI perl code I just have it pulling a
String from the registry as shown.

#==========Perl Code====================
#!perl
use Win32::OLE;
use Warnings;
use constant HKEY_CURRENT_USER => 0x80000001;
use constant HKEY_LOCAL_MACHINE => 0x80000002;
$strComputer = '.';

$oReg =
Win32::OLE->GetObject('winmgmts:{impersonationLevel=imperson ate}!\\\\' .
$strComputer . '\\root\\default:StdRegProv');

$strKeyPath = "SOFTWARE\\Microsoft\\Windows
NT\\CurrentVersion\\HotFix\\KB896424";
$strValueName = "Comments";
$oReg->GetStringValue(HKEY_LOCAL_MACHINE,$strKeyPath,$strVal ueName,$strValue);
print 'The Comment is : ' . $strValue, "\n";
#============

' =========VBSCRIPT CODE===================
const HKEY_CURRENT_USER = &H80000001
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\ " &
strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Microsoft\Windows
NT\CurrentVersion\HotFix\KB896424"
strValueName = "Comments"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
wscript.echo "The Comment is : " & strValue
'============================================

Thanks for all of your help

Tony B. Okusanya
Distributed Technology Group


"Live Life By Design And Not From Crisis to Crisis"



------------------------------------------------------------ ------------------
Electronic Privacy Notice. This e-mail, and any attachments, contains information that is, or may be, covered by electronic communications privacy laws, and is also confidential and proprietary in nature. If you are not the intended recipient, please be advised that you are legally prohibited from retaining, using, copying, distributing, or otherwise disclosing this information in any manner. Instead, please reply to the sender that you have received this communication in error, and then immediately delete it. Thank you in advance for your cooperation.
============================================================ ==================

--=_alternative 0063A4CB862570EC_=
Content-Type: text/html;
charset=us-ascii
Content-Transfer-Encoding: 7bit



Bill Luebkert Wrote








"$Bill Luebkert"
<dbecoll@adelphia.net>

12/21/2005 04:25 PM







To

"'Anthony Okusanya'" <anthony.okusanya@usbank.com>

cc

activeperl@listserv.ActiveState.com

Subject

Re: Perl Script on x64 Windows














Jan Dubois wrote:



> On Wed, 21 Dec 2005, Anthony Okusanya wrote:

>

>>Hi all I have a utility I wrote using ActivePerl. It is used to

>>install applications and hotfixes on Windows servers. I am trying
to

>>modify this to work with the 64bit version of Windows 2003. The

>>problem is that due to the registry re-direction that 64it uses
to

>>maintain 32bit compatibility, my script is not reading the registry

>>keys properly.

>

>

> You could try working around the registry redirection by using Windows

> Scripting Host.  I haven't tried this, but it is likely that
those will

> be 64 bit components and run outside the WOW64 subsystem.

>

> Here is some minimal sample to read a value (use some other key, as
the

> default value for "HotFix" is normally not set):

>

>   use Win32::OLE;

>   my $shell = Win32::OLE->new("WScript.Shell");

>   print $shell->RegRead('HKLM\\SOFTWARE\\Microsoft\\Windows
NT\\CurrentVersion\\HotFix\\');



This works for 32 bit:



use Win32::OLE;

my $shell = Win32::OLE->new("WScript.Shell");

my $ret = $shell->RegRead("HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\KB896424\\Installed")
or warn "RegRead: " . Win32::OLE->LastError();

print "$ret\n";



Wouldn't work until I took it down to the Installed subkey.



> You do have to use backslashes in the keyname.  Run with `perl
-w` to get

> all error messages if something goes wrong.

>

> Here is a link to the RegRead() documentation:

>

>   http://msdn.microsoft.com/library/default.asp?url=/library/e n-us/script56/html/af4423b2-4ee8-41d6-a704-49926cd4d2e8.asp

>

> Please report back if this works around the problem or not.






I would like to thank everyone for their
input on this issue. I appologize for my late response as I have been trying
to


implement most of the suggestions that
were sent out on this.




Jan's code sample below produced the
same result on the x64bit machine as it is still being directed to the
32bit registry section


---

use Win32::OLE;

my $shell = Win32::OLE->new("WScript.Shell");

print $shell->RegRead('HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\HotFix\\');


----



I am currently trying to use WMI to
make the registry calls however my code (shown below) does not seem to
work.


The VBScript equivalent however does
work ( I used Activestates PDK VBscript converter to generate the perl
code)


Can any one help me with this WMI perl
code I just have it pulling a String from the registry as shown.




#==========Perl Code====================

#!perl

use Win32::OLE;

use Warnings;

use constant HKEY_CURRENT_USER =>
0x80000001;


use constant HKEY_LOCAL_MACHINE =>
0x80000002;


$strComputer = '.';



$oReg = Win32::OLE->GetObject('winmgmts:{impersonationLevel=impersonate}!\\\\'
.. $strComputer . '\\root\\default:StdRegProv');




$strKeyPath = "SOFTWARE\\Microsoft\\Windows
NT\\CurrentVersion\\HotFix\\KB896424";


$strValueName = "Comments";

$oReg-> GetStringValue(HKEY_LOCAL_MACHINE,$strKeyPath,$strValueName, $strValue);

print 'The Comment is : ' . $strValue,
"\n";


#============



' =========VBSCRIPT CODE===================

const HKEY_CURRENT_USER = &H80000001

const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

 

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\ "
& strComputer & "\root\default:StdRegProv")




strKeyPath = "SOFTWARE\Microsoft\Windows
NT\CurrentVersion\HotFix\KB896424"


strValueName = "Comments"

oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

wscript.echo "The Comment is :
" & strValue


'============================================



Thanks for all of your help



Tony B. Okusanya

Distributed Technology Group





"Live Life By Design And Not From Crisis to Crisis"







------------------------------------------------------------ ------------------

Electronic Privacy Notice. This e-mail, and any attachments, contains information that is, or may be, covered by electronic communications privacy laws, and is also confidential and proprietary in nature. If you are not the intended recipient, please be advised that you are legally prohibited from retaining, using, copying, distributing, or otherwise disclosing this information in any manner. Instead, please reply to the sender that you have received this communication in error, and then immediately delete it. Thank you in advance for your cooperation.

============================================================ ==================


--=_alternative 0063A4CB862570EC_=--


--===============1026005978==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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

Re: Perl Script on x64 Windows

am 05.01.2006 00:41:50 von dbecoll

anthony.okusanya@usbank.com wrote:

> I would like to thank everyone for their input on this issue. I
> appologize for my late response as I have been trying to
> implement most of the suggestions that were sent out on this.
>
> Jan's code sample below produced the same result on the x64bit machine
> as it is still being directed to the 32bit registry section
> ---
> use Win32::OLE;
> my $shell = Win32::OLE->new("WScript.Shell");
> print $shell->RegRead('HKLM\\SOFTWARE\\Microsoft\\Windows
> NT\\CurrentVersion\\HotFix\\');
> ----
>
> I am currently trying to use WMI to make the registry calls however my
> code (shown below) does not seem to work.
> The VBScript equivalent however does work ( I used Activestates PDK
> VBscript converter to generate the perl code)
> Can any one help me with this WMI perl code I just have it pulling a
> String from the registry as shown.
>
> #==========Perl Code====================
> #!perl
> use Win32::OLE;
> use Warnings;
> use constant HKEY_CURRENT_USER => 0x80000001;
> use constant HKEY_LOCAL_MACHINE => 0x80000002;
> $strComputer = '.';
>
> $oReg =
> Win32::OLE->GetObject('winmgmts:{impersonationLevel=imperson ate}!\\\\' .
> $strComputer . '\\root\\default:StdRegProv');
>
> $strKeyPath = "SOFTWARE\\Microsoft\\Windows
> NT\\CurrentVersion\\HotFix\\KB896424";
> $strValueName = "Comments";
> $oReg->GetStringValue(HKEY_LOCAL_MACHINE,$strKeyPath,$strVal ueName,$strValue);
>
> print 'The Comment is : ' . $strValue, "\n";
> #============
>
> ' =========VBSCRIPT CODE===================
> const HKEY_CURRENT_USER = &H80000001
> const HKEY_LOCAL_MACHINE = &H80000002
> strComputer = "."
>
> Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\ " &
> strComputer & "\root\default:StdRegProv")
>
> strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix\KB896424"
> strValueName = "Comments"
> oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
> wscript.echo "The Comment is : " & strValue
> '============================================

This seems to work on 32:

use strict;
use warnings;
use Win32::OLE;
use Win32::OLE::Variant;

use constant HKEY_CURRENT_USER => 0x80000001;
use constant HKEY_LOCAL_MACHINE => 0x80000002;

my $strComputer = Win32::NodeName || '.';

my $oReg = Win32::OLE->GetObject(
'winmgmts:{impersonationLevel=impersonate}!\\\\' . $strComputer .
'\\root\\default:StdRegProv') or die "GetObject: " . Win32::OLE->LastError();

my $path = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\HotFix\\KB896424";

my @names = ('', 'Backup Dir', 'Comments', 'Fix Description', 'Installed',
'Installed By', 'Installed On', 'Service Pack', 'Valid');
my @types = (VT_BSTR, VT_BSTR, VT_BSTR, VT_BSTR, VT_I4, VT_BSTR, VT_BSTR,
VT_I4, VT_I4);

my $strKeyPath = $path;
for (my $ii = 0; $ii < @names; ++$ii) {

my $strValueName = $names[$ii];

if ($types[$ii] == VT_BSTR) {
my $strValue = Variant (VT_BSTR|VT_BYREF, '');
my $ret = $oReg->GetStringValue(HKEY_LOCAL_MACHINE,
$strKeyPath, $strValueName, $strValue);
$strValueName = '(Default)' if not $strValueName;
print "$strValueName: '", $strValue->Value(), "'\n";
} else {
my $Value = Variant (VT_I4|VT_BYREF, 0);
my $ret = $oReg->GetDWORDValue(HKEY_LOCAL_MACHINE,
$strKeyPath, $strValueName, $Value);
print "$strValueName: '", $Value->Value(), "'\n";
}
}

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

Re: Perl Script on x64 Windows

am 05.01.2006 20:53:59 von anthony.okusanya

This is a multipart message in MIME format.
--===============0511291424==
Content-Type: multipart/alternative;
boundary="=_alternative 006D4FEE862570ED_="

This is a multipart message in MIME format.
--=_alternative 006D4FEE862570ED_=
Content-Type: text/plain;
charset=us-ascii
Content-Transfer-Encoding: 7bit

Bill Luebkert wrote:

This seems to work on 32:

use strict;
use warnings;
use Win32::OLE;
use Win32::OLE::Variant;

use constant HKEY_CURRENT_USER => 0x80000001;
use constant HKEY_LOCAL_MACHINE => 0x80000002;

my $strComputer = Win32::NodeName || '.';

my $oReg = Win32::OLE->GetObject(
'winmgmts:{impersonationLevel=impersonate}!\\\\' . $strComputer .
'\\root\\default:StdRegProv') or die "GetObject: " .
Win32::OLE->LastError();

my $path = "SOFTWARE\\Microsoft\\Windows
NT\\CurrentVersion\\HotFix\\KB896424";

my @names = ('', 'Backup Dir', 'Comments', 'Fix Description', 'Installed',
'Installed By', 'Installed On', 'Service Pack', 'Valid');
my @types = (VT_BSTR, VT_BSTR, VT_BSTR, VT_BSTR, VT_I4, VT_BSTR, VT_BSTR,
VT_I4, VT_I4);

my $strKeyPath = $path;
for (my $ii = 0; $ii < @names; ++$ii) {

my $strValueName = $names[$ii];

if ($types[$ii] == VT_BSTR) {
my $strValue = Variant (VT_BSTR|VT_BYREF,
'');
my $ret =
$oReg->GetStringValue(HKEY_LOCAL_MACHINE,
$strKeyPath, $strValueName, $strValue);
$strValueName = '(Default)' if not
$strValueName;
print "$strValueName: '",
$strValue->Value(), "'\n";
} else {
my $Value = Variant (VT_I4|VT_BYREF, 0);
my $ret =
$oReg->GetDWORDValue(HKEY_LOCAL_MACHINE,
$strKeyPath, $strValueName, $Value);
print "$strValueName: '",
$Value->Value(), "'\n";
}
}

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



Thanks for that code Bill I tested it on Win32 and it works just fine.
However
the x64 OS is still treating the code as a 32bit app and is redirecting
any and all registry
queries (WMI or via WSH) to the 32bit registy tree.
Not sure what else to do as we use this utility to update applications and
security patches.
If anyone has a way of telling the OS that a perl script requires 64bit
access and not 32 I would be grateful.

Thanks all
------------------------------------------------------------ ------------------
Electronic Privacy Notice. This e-mail, and any attachments, contains information that is, or may be, covered by electronic communications privacy laws, and is also confidential and proprietary in nature. If you are not the intended recipient, please be advised that you are legally prohibited from retaining, using, copying, distributing, or otherwise disclosing this information in any manner. Instead, please reply to the sender that you have received this communication in error, and then immediately delete it. Thank you in advance for your cooperation.
============================================================ ==================

--=_alternative 006D4FEE862570ED_=
Content-Type: text/html;
charset=us-ascii
Content-Transfer-Encoding: 7bit







Bill Luebkert wrote:



This seems to work on 32:



use strict;

use warnings;

use Win32::OLE;

use Win32::OLE::Variant;



use constant HKEY_CURRENT_USER => 0x80000001;

use constant HKEY_LOCAL_MACHINE => 0x80000002;



my $strComputer = Win32::NodeName || '.';



my $oReg = Win32::OLE->GetObject(

 'winmgmts:{impersonationLevel=impersonate}!\\\\' . $strComputer
..

 '\\root\\default:StdRegProv') or die "GetObject: " . Win32::OLE->LastError();



my $path = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\HotFix\\KB896424";



my @names = ('', 'Backup Dir', 'Comments', 'Fix Description', 'Installed',

 'Installed By', 'Installed On', 'Service Pack', 'Valid');

my @types = (VT_BSTR, VT_BSTR, VT_BSTR, VT_BSTR, VT_I4, VT_BSTR, VT_BSTR,

 VT_I4, VT_I4);



my $strKeyPath = $path;

for (my $ii = 0; $ii < @names; ++$ii) {



               
my $strValueName = $names[$ii];



               
if ($types[$ii] == VT_BSTR) {

               
                 my
$strValue = Variant (VT_BSTR|VT_BYREF, '<Not Set>');

               
                 my
$ret = $oReg->GetStringValue(HKEY_LOCAL_MACHINE,

               
                 
 $strKeyPath, $strValueName, $strValue);

               
                 $strValueName
= '(Default)' if not $strValueName;

               
                 print
"$strValueName: '", $strValue->Value(), "'\n";

               
} else {

               
                 my
$Value = Variant (VT_I4|VT_BYREF, 0);

               
                 my
$ret = $oReg->GetDWORDValue(HKEY_LOCAL_MACHINE,

               
                 
 $strKeyPath, $strValueName, $Value);

               
                 print
"$strValueName: '", $Value->Value(), "'\n";

               
}

}



__END__

_______________________________________________

ActivePerl mailing list

ActivePerl@listserv.ActiveState.com

To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs







Thanks for that code Bill I tested it
on Win32 and it works just fine. However


the x64 OS is still treating the code
as a 32bit app and is redirecting any and all registry


queries (WMI or via WSH) to the 32bit
registy tree.


Not sure what else to do as we use this
utility to update applications and security patches.


If anyone has a way of telling the OS
that a perl script requires 64bit access and not 32 I would be grateful.




Thanks all

------------------------------------------------------------ ------------------

Electronic Privacy Notice. This e-mail, and any attachments, contains information that is, or may be, covered by electronic communications privacy laws, and is also confidential and proprietary in nature. If you are not the intended recipient, please be advised that you are legally prohibited from retaining, using, copying, distributing, or otherwise disclosing this information in any manner. Instead, please reply to the sender that you have received this communication in error, and then immediately delete it. Thank you in advance for your cooperation.

============================================================ ==================


--=_alternative 006D4FEE862570ED_=--


--===============0511291424==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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

Re: Perl Script on x64 Windows

am 26.01.2006 22:41:37 von anthony.okusanya

This is a multipart message in MIME format.
--===============0049645186==
Content-Type: multipart/alternative;
boundary="=_alternative 00772B2186257102_="

This is a multipart message in MIME format.
--=_alternative 00772B2186257102_=
Content-Type: text/plain;
charset=us-ascii
Content-Transfer-Encoding: 7bit

Anthony Okusanya wrote:

> Hi all
> I have a utility I wrote using ActivePerl. It is used to install
applications and hotfixes on Windows servers. I am trying to modify this
to work with the 64bit version of Windows 2003. The problem is that due to
the registry re-direction that 64it uses to maintain 32bit compatibility,
my script is not reading the registry keys properly.
> Here is a sample of my script. the CHKPATCH subroutine is used to test
for the existence of a patch
> e.g to determine if KB896424 is installed I simply call
CHKPATCH("KB896424").
> On 64bit, this utility does not read the registry key listed below
because its running in 32 bit mode
> even though I can see the key when I run Regedit from the server.
>
> use Win32::TieRegistry(Delimiter=>"/");
> .......
> sub CHKPATCH
> {
> my $hotfix;
> if($hotfix =$Registry->{"LMachine/SOFTWARE/Microsoft/Windows
NT/CurrentVersion/HotFix/$_[0]"})
> {
> return 1;
> }
> else
> {
> return 0;
> }
>
> }
>
> Sorry for Rambling on and on but if anyone has any ideas I would be most
appreciative

**********
In my search for a solution to the problem I was having accessing 64bit
registry view on a 64bit Windows OS
I reviewed Microsoft's information on accessing an alternate registry view
(http://msdn.microsoft.com/library/default.asp?url=/library/ en-us/win64/win64/accessing_an_alternate_registry_view.asp)
Microsoft's 64bit registry access now defines the following constants

KEY_WOW64_64KEY 0x0100 Access a 64-bit key from either a 32-bit or 64-bit
application.
KEY_WOW64_32KEY 0x0200 Access a 32-bit key from either a 32-bit or 64-bit
application.

I also reviewed the documentation of Tye McQueen's Win32::TieRegistry
module and
added the following lines of code to the TieRegistry.pm file to use the
above constants

sub KEY_WOW64_64KEY () { 0x0100}
sub KEY_WOW64_32KEY () { 0x0200}

Finally I changed the following code in TieRegistry.pm to include 64bit
registry access by Oring (|) the above constants with KEY_READ

=======Original=================
# Basic master Registry object:
$RegObj= {};
@$RegObj{qw( HANDLE MACHINE PATH DELIM OS_DELIM ACCESS FLAGS ROOTS )}= (
"NONE", "", [], "\\", "\\",
KEY_READ|KEY_WRITE, $Flag_HexDWord|$Flag_FixNulls, "${PACK}::_Roots"
);
=================================

=======Updated===========
# Basic master Registry object:
$RegObj= {};
@$RegObj{qw( HANDLE MACHINE PATH DELIM OS_DELIM ACCESS FLAGS ROOTS )}= (
"NONE", "", [], "\\", "\\",
KEY_READ|KEY_WRITE|KEY_WOW64_64KEY|KEY_WOW64_32KEY,
$Flag_HexDWord|$Flag_FixNulls, "${PACK}::_Roots" );

I know this probably isnt the best way to make these changes and but it
did the trick
I am able to use this script on both Win32 and x64 windows systems to
access the registry.
I am copying Tye on this email. I hope an updated version of the module
will be released soon

Thanks everyone for the many replies on this problem

Tony B. Okusanya
Distributed Technology Group
"Live Life By Design And Not From Crisis to Crisis"

------------------------------------------------------------ ------------------
Electronic Privacy Notice. This e-mail, and any attachments, contains information that is, or may be, covered by electronic communications privacy laws, and is also confidential and proprietary in nature. If you are not the intended recipient, please be advised that you are legally prohibited from retaining, using, copying, distributing, or otherwise disclosing this information in any manner. Instead, please reply to the sender that you have received this communication in error, and then immediately delete it. Thank you in advance for your cooperation.
============================================================ ==================

--=_alternative 00772B2186257102_=
Content-Type: text/html;
charset=us-ascii
Content-Transfer-Encoding: 7bit



Anthony Okusanya wrote:



> Hi all

>       I have a utility I wrote using ActivePerl. It
is used to install applications and hotfixes on Windows servers. I am trying
to modify this to work with the 64bit version of Windows 2003. The problem
is that due to the registry re-direction that 64it uses to maintain 32bit
compatibility, my script is not reading the registry keys properly.

> Here is a sample of my script. the CHKPATCH subroutine is used to
test for the existence of a patch

> e.g to determine if KB896424 is installed I simply call CHKPATCH("KB896424").

> On 64bit, this utility does not read the registry key listed below
because its running in 32 bit mode

> even though I can see the key when I run Regedit from the server.

>

> use Win32::TieRegistry(Delimiter=>"/");

> .......

> sub CHKPATCH

> {

>     my $hotfix;

>     if($hotfix =$Registry->{"LMachine/SOFTWARE/Microsoft/Windows
NT/CurrentVersion/HotFix/$_[0]"})

>     {

>         return 1;

>     }

>     else

>     {

>       return 0;

>     }

>    

> }

>

> Sorry for Rambling on and on but if anyone has any ideas I would be
most appreciative




**********

In my search for a solution to the problem
I was having accessing 64bit registry view on a 64bit Windows OS


I reviewed Microsoft's information on
accessing an alternate registry view (http://msdn.microsoft.com/library/default.asp?url=/library/ en-us/win64/win64/accessing_an_alternate_registry_view.asp)


Microsoft's 64bit registry access now
defines the following constants




KEY_WOW64_64KEY 0x0100 Access a 64-bit
key from either a 32-bit or 64-bit application.


KEY_WOW64_32KEY 0x0200 Access a 32-bit
key from either a 32-bit or 64-bit application.




I also reviewed the documentation of
Tye McQueen's Win32::TieRegistry module and


added the following lines of code to
the TieRegistry.pm file  to use the above constants




sub KEY_WOW64_64KEY () { 0x0100}

sub KEY_WOW64_32KEY () { 0x0200}



Finally I changed the following code
in TieRegistry.pm to include 64bit registry access by Oring (|) the above
constants with KEY_READ




=======Original=================

# Basic master Registry object:

$RegObj= {};

@$RegObj{qw( HANDLE MACHINE PATH DELIM
OS_DELIM ACCESS FLAGS ROOTS )}= (


    "NONE", "",
[], "\\", "\\",


    KEY_READ|KEY_WRITE, $Flag_HexDWord|$Flag_FixNulls,
"${PACK}::_Roots" );


=================================



=======Updated===========

# Basic master Registry object:

$RegObj= {};

@$RegObj{qw( HANDLE MACHINE PATH DELIM
OS_DELIM ACCESS FLAGS ROOTS )}= (


    "NONE", "",
[], "\\", "\\",


    KEY_READ|KEY_WRITE|KEY_WOW64_64KEY|KEY_WOW64_32KEY,
$Flag_HexDWord|$Flag_FixNulls, "${PACK}::_Roots" );




I know this probably isnt the best way
to make these changes and but it did the trick


I am able to use this script on both
Win32 and x64 windows systems to access the registry.


I am copying Tye on this email. I hope
an updated version of the module will be released soon




Thanks everyone for the many replies
on this problem




Tony B. Okusanya

Distributed Technology Group

"Live Life By Design And Not From Crisis to Crisis"



------------------------------------------------------------ ------------------

Electronic Privacy Notice. This e-mail, and any attachments, contains information that is, or may be, covered by electronic communications privacy laws, and is also confidential and proprietary in nature. If you are not the intended recipient, please be advised that you are legally prohibited from retaining, using, copying, distributing, or otherwise disclosing this information in any manner. Instead, please reply to the sender that you have received this communication in error, and then immediately delete it. Thank you in advance for your cooperation.

============================================================ ==================


--=_alternative 00772B2186257102_=--


--===============0049645186==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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