Determining if a Windows Server?

2002-10-10 Thread Hawley, Eric

I need to be able to determine whether or not the computer that a script is
running on is a Windows NT or 2000 server or if it is not.  Does anyone know
how to do this? I tried looking at Win32::GetOSVersion() but this won't
work.  I have tried searching on CPAN but haven't found anything.  

Thanks

*   Eric Hawley, Network Services Intern
 * Office of Information Technology
 * Ohio Department of Natural Resources
 * Phone:  (614) 265-1028
 * Mailto:[EMAIL PROTECTED]
 
 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: Determining if a Windows Server?

2002-10-10 Thread Alan Dickey

Hawley, Eric wrote:
 
 I need to be able to determine whether or not the computer that a script is
 running on is a Windows NT or 2000 server or if it is not.  Does anyone know
 how to do this? I tried looking at Win32::GetOSVersion() but this won't
 work.  I have tried searching on CPAN but haven't found anything.

how about $^O (see perldoc perlfunc)

-- 
Alan F. Dickey - Interaction and Realization
http://www.intac.com/~afdickey
mailto:[EMAIL PROTECTED]
VOX: 908-273-3232 Cell: 908-334-0932

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Determining if a Windows Server?

2002-10-10 Thread Tony White

Whew!  I thought this was an easy one, but I just spent nearly an hour
finding out *any* way to find this out.  And here it is:

Look at the contents of the following registry value:

HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/ProductOptions/ProductTy
pe

It will have one of 3 values:

WinNT   -- Workstation (or Professional for Win2K)
ServerNT-- Server 
LanmanNT-- Advanced Server (but I found this on an NT PDC, too)

-Original Message-
From: Alan Dickey [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 10, 2002 7:50 AM
Cc: '[EMAIL PROTECTED]'
Subject: Re: Determining if a Windows Server?


Hawley, Eric wrote:
 
 I need to be able to determine whether or not the computer that a script
is
 running on is a Windows NT or 2000 server or if it is not.  Does anyone
know
 how to do this? I tried looking at Win32::GetOSVersion() but this won't
 work.  I have tried searching on CPAN but haven't found anything.

how about $^O (see perldoc perlfunc)

-- 
Alan F. Dickey - Interaction and Realization
http://www.intac.com/~afdickey
mailto:[EMAIL PROTECTED]
VOX: 908-273-3232 Cell: 908-334-0932

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: Determining if a Windows Server?

2002-10-10 Thread Alan Dickey

Tony White wrote:
 
 Whew!  I thought this was an easy one, but I just spent nearly an hour
 finding out *any* way to find this out.  And here it is:
 
 Look at the contents of the following registry value:
 
 HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/ProductOptions/ProductTy
 pe
 
 It will have one of 3 values:
 
 WinNT   -- Workstation (or Professional for Win2K)
 ServerNT-- Server
 LanmanNT-- Advanced Server (but I found this on an NT PDC, too)

Thanks, Tony!

As a summary for those interested, I put together this little script:

--
use Win32;

# compare various OS info:

print \$^O = '$^O'\n;
my @osinfo = Win32::GetOSVersion();
print Win32::GetOSVersion() = '@osinfo'\n;
@osinfo = Win32::GetOSName();
print Win32::GetOSName() = '@osinfo'\n;

use Win32::TieRegistry;
my $producttype = 

$Registry-{'HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\ProductOptionsProduct

Type'};
print
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/ProductOptions\\ProductType
= 

'$producttype'\n;
--

on my machine (W2K Professional SP3) this produces:

$^O = 'MSWin32'
Win32::GetOSVersion() = 'Service Pack 3 5 0 2195 2'
Win32::GetOSName() = 'Win2000 Service Pack 3'
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/ProductOptions\ProductType
=
 'WinNT'

Cheers.

-- 
Alan F. Dickey - Interaction and Realization
http://www.intac.com/~afdickey
mailto:[EMAIL PROTECTED]
VOX: 908-273-3232 Cell: 908-334-0932

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: Determining if a Windows Server?

2002-10-10 Thread $Bill Luebkert

Alan Dickey wrote:
 Tony White wrote:
 
Whew!  I thought this was an easy one, but I just spent nearly an hour
finding out *any* way to find this out.  And here it is:

Look at the contents of the following registry value:

HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/ProductOptions/ProductTy
pe

It will have one of 3 values:

WinNT   -- Workstation (or Professional for Win2K)
ServerNT-- Server
LanmanNT-- Advanced Server (but I found this on an NT PDC, too)
 
 
 Thanks, Tony!
 
 As a summary for those interested, I put together this little script:
 
 --
 use Win32;
 
 # compare various OS info:
 
 print \$^O = '$^O'\n;
 my @osinfo = Win32::GetOSVersion();
 print Win32::GetOSVersion() = '@osinfo'\n;
 @osinfo = Win32::GetOSName();
 print Win32::GetOSName() = '@osinfo'\n;
 
 use Win32::TieRegistry;
 my $producttype = 
 
 
$Registry-{'HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\ProductOptionsProduct
 
 Type'};
 print
 HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/ProductOptions\\ProductType
 = 
 
 '$producttype'\n;
 --
 
 on my machine (W2K Professional SP3) this produces:
 
 $^O = 'MSWin32'
 Win32::GetOSVersion() = 'Service Pack 3 5 0 2195 2'
 Win32::GetOSName() = 'Win2000 Service Pack 3'
 HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/ProductOptions\ProductType
 =
  'WinNT'

That doesn't exist on my 98 box.  Try this one (works on 98SE) and see if it works 
there:

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

my $reg = $Registry-{'LMachine/Software/Microsoft/Windows/CurrentVersion/'}
   or die Can't find the Windows CurrentVersion key: $^E;
my $ProductName = $reg-{ProductName};
my $ProductType = $reg-{ProductType};
my $Version = $reg-{Version};
my $SubVersionNumber = $reg-{SubVersionNumber};
my $VersionNumber = $reg-{VersionNumber};

print ProductName='$ProductName'\n;
print ProductType='$ProductType'\n;
print Version='$Version'\n;
print SubVersionNumber='$SubVersionNumber'\n;
print VersionNumber='$VersionNumber'\n;

__END__

Also what do get get for this PSIX version:

use strict;
use POSIX qw(uname);
my @a = uname ();
my @tags = qw(OS-Name Hostname OS-Version OS-Release Machine-Type);
foreach (my $ii = 0; $ii  @a; $ii++) { print $tags[$ii]: $a[$ii]\n; }

__END__

-- 
   ,-/-  __  _  _ $Bill Luebkert   ICQ=162126130
  (_/   /  )// //   DBE Collectibles   Mailto:[EMAIL PROTECTED]
   / ) /--  o // //  http://dbecoll.tripod.com/ (Free site for Perl)
-/-' /___/__/_/_ Castle of Medieval Myth  Magic http://www.todbe.com/

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs