Page 1 of 1 1
Topic Options
#181040 - 2007-10-02 06:16 PM OS Type
Graham Offline
Lurker

Registered: 2007-10-02
Posts: 1
Hi

I have a login script that uses the OS Type to determine if a pc is a server or workstation the code is -

If (:inwin=1)
$OS_Type ="NT"
Else
$OS_Type ="9x"
Endif

The script works fine on all PC's apart from Vista clients? Could any shed some light as to why?

Thanks

Top
#181042 - 2007-10-02 07:01 PM Re: OS Type [Re: Graham]
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
I can't even understand why it works at all right now since the snippet does seem to be incomplete. Second, it seems pretty foolish to search for NT - and guessing that it would be a server if it fitted the string searched for.
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#181043 - 2007-10-02 07:19 PM Re: OS Type [Re: Björn]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
This is what I use, from the @PRODUCTTYPE macro when run locally:
 Code:
$CType = IIf(InStr(@PRODUCTTYPE, 'Server') Or InStr(@PRODUCTTYPE, 'Controller'), 'Server', 'Workstation')

For remote systems, I use something like:
 Code:
; Base registry paths for registry reads  $_RegCtrl='HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\'
$_OS_Type = ReadValue($_Target + $_RegCtrl + 'ProductOptions', 'ProductType')
$CType = IIf(InStr('LanManNTServerNT', $_OS_Type), 'Server','Workstation')


Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#181044 - 2007-10-02 07:21 PM Re: OS Type [Re: Graham]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Your script is not properly formatted and therefore will never work. Unless it is not kixtart but some other scripting language.

Some issues with the code you posted:
- In kixtart variables or macro's have a $ (variable) or a @ (macro) as first character not a :.
- If is not a function so there is no need for the brackets.

This should work.
 Code:
Select
	Case InStr(@PRODUCTTYPE, "Windows NT")
		$OS_Type = "WinNT"
	Case InStr(@PRODUCTTYPE, "Windows 2000")
		$OS_Type = "Win2K"
	Case InStr(@PRODUCTTYPE, "Windows XP")
		$OS_Type = "WinXP"
	Case InStr(@PRODUCTTYPE, "Windows Vista")
		$OS_Type = "WinVista"
EndSelect


Edited by Mart (2007-10-02 07:25 PM)
Edit Reason: Woops used the wrong macro.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#181045 - 2007-10-02 08:00 PM Re: OS Type [Re: Mart]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Mart - Windows NT and Windows 2000 have both Server and Workstation versions. The question was to differentiate between Server and Workstation systems.

Server systems always identify that extra piece of info, although domain controllers don't have the word "server". The logic I presented earlier looks for the key words "server" or "controller" to identify a server, and assumes anything lacking those words is a workstation. This works on every environment I've tested, including W9x, NT, W2K, XP, & W2K3. I'll be loading up several versions of Vista in the coming week to verify those environments as well. I haven't tested Windows 2008 yet, but would assume it hasn't changed much.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#181048 - 2007-10-02 08:48 PM Re: OS Type [Re: Glenn Barnas]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
D#mn. Now I should really learn to read better. Said it before but today it seems like it is true. I'm having a bad day today. All day long these stupid things I'm glad work is over and I'm at home Where I can do whatever I want.

 Code:
If InStr(@PRODUCTTYPE, "Server") OR InStr(@PRODUCTTYPE, "Domain controller")
	$OS_type = "Server or DC"
Else
	$OS_type = "Workstation"
EndIf


Edited by Mart (2007-10-02 08:49 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#181055 - 2007-10-02 11:25 PM Re: OS Type [Re: Glenn Barnas]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Well if you just want to differentiate from WORKSTATION and SERVER then only look for WinNT on the registry read. ALL workstations use WinNT and the Servers as you know use a variety of different values.

So IF it matches WinNT then it is a workstation, otherwise it's a Server.
Then if you need to know which server is when you'd need to use some other code.

Top
#181060 - 2007-10-03 02:50 AM Re: OS Type [Re: NTDOC]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
True if you're a totally 32b environment. The first post talked about nt and w9x. My solution works on all platforms while yours only works on NT and higher. Shouldn't be an issue in most environments, but hey - there's still people posting about having W98 systems (cringe).

G-
_________________________
Actually I am a Rocket Scientist! \:D

Top
#181068 - 2007-10-03 05:56 AM Re: OS Type [Re: Glenn Barnas]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Well true there are shops out there like that but they would also have to be on an NT4 Domain as AD doesn't support Win9x logins as I recall (been long time).

Just glad I'm not in that boat

Top
#181071 - 2007-10-03 06:25 AM Re: OS Type [Re: NTDOC]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
 Originally Posted By: NTDOC
...AD doesn't support Win9x logins as I recall (been long time).
Too long
9x cannot join the domain be it NT4 or AD but otherwise the users can logon to either.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#181072 - 2007-10-03 06:37 AM Re: OS Type [Re: Les]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Well I know it can't JOIN either Domain but didn't remember if it could login to AD. Does it need the ADSI or what ever add-on that was to do a login for AD or is that just to support group stuff ?
Top
#181116 - 2007-10-04 06:54 AM Re: OS Type [Re: NTDOC]
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
If I remember correctly, you need Microsoft's Active Directory client extension (Dsclient.exe), also called the Directory Services Client.
_________________________
There are two types of vessels, submarines and targets.

Top
#181162 - 2007-10-05 03:23 PM Re: OS Type [Re: Sealeopard]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
I presume that is only needed for Active Directory related stuff? How was it done in the legacy days? How do legacy logon scripts run?
Top
#181190 - 2007-10-06 06:28 AM Re: OS Type [Re: Witto]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Don't quote me but as I remember if you used the NETLOGON share then Win9x could see and use it, but if you used the policy folder locations for scripts then Win9x could not see it without the ADSI client.

Think maybe we're a bit off topic but the original poster seems to have not come back so not too bad I suppose.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1636 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.102 seconds in which 0.028 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org