Bill Luebkert Wrote


"$Bill Luebkert" <[EMAIL PROTECTED]>

12/21/2005 04:25 PM

To
"'Anthony Okusanya'" <[EMAIL PROTECTED]>
cc
[email protected]
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=""> >
> 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.
==============================================================================

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

Reply via email to