Jump to content

@OSVersion


bourny
 Share

Recommended Posts

OSVersion

Returns one of the following: "WIN_2003", "WIN_XP", "WIN_2000", "WIN_NT4", "WIN_ME", "WIN_98", "WIN_95"

The problem I am having is how to differentiate between windows 2000 server and windows 2000 client. The @OSversion and @OSBuild return the same values. This seems to be something unique to win2k.

Apart from detecting a unique file is there any standard registry entry I can read in or any combination of AutoIt function I have missed to nail this problem....

As you can appreciate I am unwilling to pick up a file as this can vary between systems - However OSversion and build are ideal if the client and server are different, wjich is not the case with windows 2000

Thanks

Link to comment
Share on other sites

I have seen this question asked before without any answer so here is a suggestion.

Search the registry for the word server and see if it is in a key that is likely to be unique to a server, if it is you will be able to use that.

Poor answer but at least it is something to try.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

I see maybe a key like this

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Installations\x86_Microsoft.Tools.VisualCPlusPlus.Runtime-Libraries_6595b64144ccf1df_6.0.0.0_x-ww_ff9986d7\Codebases\OS]

"Prompt"="Windows XP Professional Service Pack 1 CD"

i dont have 2000, so i dont know if that key is there

Edited by ACalcutt

Andrew Calcutt

Http://www.Vistumbler.net

Http://www.TechIdiots.net

Its not an error, its a undocumented feature

Link to comment
Share on other sites

I have managed to find some files that I can pick up on. Browsers of this post might find this helpfull.

The following files only exist on servers.

File = $systemroot\system32\rrasmgmt.msc - Common to win2k / 2003 server (Ras Management)

File = $systemroot\system32\srvwiz.dll - Common to win2k server (Configure server dll)

File = $systemroot\system32\cys.exe - Common to 2003 server (Configure server executable)

Obviously you can use the @ostype @osversion to pick up an NT4 system if you need to ...

Link to comment
Share on other sites

what about gettype.exe... it looks like it comes with 2000, its not on my xp machin so i cant tell

http://support.microsoft.com/?kbid=190899

Too much coding to achive what I want and requires coding outside of AutoIt - Also does not cross all platforms including windows xp / 2003 - However this is a neat little utility - Good Find....

Thanks

bourny

Link to comment
Share on other sites

Here is my final code to abort on a server

If FileExists(@SystemDir & "\srvmgr.exe") or FileExists(@SystemDir & "\rrasmgmt.msc") or FileExists(@SystemDir & "\cys.exe") or FileExists(@SystemDir & "\srvwiz.dll") Then

SplashTextOn ("", "Server Detected - Aborting Package", 260, 20, -1 ,-1 ,1 ,"" ,"10" ,"600")

Sleep(5000)

Exit

EndIf

Link to comment
Share on other sites

Something I have already tried but I cannot pin down a default server key....

This should do the trick.

;===============================================================================
;
; Function Name:    _CpuRole()
; Description:    Returns the role of the computer as an integer or string
; Parameter(s):  $strComputer = 'localhost' - Default is current computer (localhost)
;                                   Can be remote computer name or IP address (NOT WELL TESTED)
;
;                   $iRetType = 1 - 1 = Return a string,
;                                       anything else will return an integer as follows:
;                                       0 = 'Standalone Workstation'
;                                       1 = 'Member Workstation'
;                                       2 = 'Standalone Server'
;                                       3 = 'Member Server'
;                                       4 = 'Backup Domain Controller'
;                                       5 = 'Primary Domain Controller'
;
; Requirement(s):   AutoIt 3.1.1 Beta
; Return Value(s):  On Success Returns the computer role as either a string or integer
;                  On Failure Returns an empty string ('')  and sets @ERROR = 1
;
; Reference:        WMI ScriptOMatic tool for AutoIt by SvenP
;                   http://www.autoitscript.com/forum/index.php?showtopic=10534&hl
; Author(s):        JerryD
;
;===============================================================================
;
Func _CpuRole($strComputer = 'localhost', $iRetType = 1)
    Dim $aRoles[6]
    $aRoles[0] = 'Standalone Workstation'
    $aRoles[1] = 'Member Workstation'
    $aRoles[2] = 'Standalone Server'
    $aRoles[3] = 'Member Server'
    $aRoles[4] = 'Backup Domain Controller'
    $aRoles[5] = 'Primary Domain Controller'
    Const $wbemFlagReturnImmediately = 0x10
    Const $wbemFlagForwardOnly = 0x20
    Local $colItems = '', $Output = '', $objWMIService, $colItems
    
; This sets defaults in case they're specified by either '' or -1
    If $strComputer = '' Or $strComputer = -1 Then
        $strComputer = 'localhost'
    EndIf
    If $iRetType = '' Or $iRetType = -1 Then
        $iRetType = 1
    ElseIf $iRetType <> 1 Then
        $iRetType = 0
    EndIf
    
; Get the info
    $objWMIService = ObjGet('winmgmts:\\' & $strComputer & '\root\CIMV2')
    $colItems = $objWMIService.ExecQuery ('SELECT * FROM Win32_ComputerSystem', 'WQL', $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
    
; Return what's found
    If Not IsObj($colItems) Then
        $objWMIService = ''
        $colItems = ''
        SetError(1)
        Return ''
    Else
        For $objItem In $colItems
            $Output = $objItem.DomainRole
        Next
        $objWMIService = ''
        $colItems = ''
        If $iRetType Then
            Return $aRoles[$Output]
        Else
            Return $Output
        EndIf
    EndIf
EndFunc  ;==>_CpuRole

Yea, I know it's a lot to go through for just that piece of information, and I'm sure it's in the registry somewhere, but I couldn't find it!

NOTE That I've only tested this against 'Standalone Workstations' - WinXP Pro and Win2k Pro.

_CpuRole.au3

Link to comment
Share on other sites

...I'm sure it's in the registry somewhere, but I couldn't find it!

You are correct. The info seems to be somewhere in the registry. From the site posted above: http://support.microsoft.com/?kbid=190899

Gettype.exe works by querying the registry for the installation type and setting the DOS ERRORLEVEL appropriately:

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

i remebered a program called NTSwitch that i used before. this program changed your operating system from pro to server and vice versa.....

the program isn't made anymore for legal reasons...but i found this post

http://www.anetforums.com/posts.aspx?ThreadIndex=28617

HOW: The operating system decides which "flavor" to run in based on two

registry values:

HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions - ProductType [REG_SZ]HKLM\SYSTEM\Setup - SystemPrefix [REG_BINARY 8 bytes]

ProductType is "ServerNT" or "LanmanNT" for servers, and "WinNT" for workstations.

The third bit in the last byte of the SystemPrefix value is set for servers,

and cleared for workstations.

-Edit

I beleive this is what you want

$ostype = RegRead ( "HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions", "ProductType" )
If $ostype = "ServerNT" Or $ostype = "LanmanNT" Then
    SplashTextOn ("", "Server Detected - Aborting Package", 260, 20, -1 ,-1 ,1 ,"" ,"10" ,"600")
    Sleep(5000)
    Exit
EndIf

If $ostype = "WinNT" Then MsgBox(0, "OS", "OS Is Workstation")
Edited by ACalcutt

Andrew Calcutt

Http://www.Vistumbler.net

Http://www.TechIdiots.net

Its not an error, its a undocumented feature

Link to comment
Share on other sites

i remebered a program called NTSwitch that i used before. this program changed your operating system from pro to server and vice versa.....

the program isn't made anymore for legal reasons...but i found this post

http://www.anetforums.com/posts.aspx?ThreadIndex=28617

ROFL, Windows is such a joke sometimes.

---"Educate the Mind, Make Savage the Body" -Mao Tse Tung

Link to comment
Share on other sites

i remebered a program called NTSwitch that i used before. this program changed your operating system from pro to server and vice versa.....

the program isn't made anymore for legal reasons...but i found this post

http://www.anetforums.com/posts.aspx?ThreadIndex=28617

Nice one - Exactly what I am looking for

The following location in the registry defines server or client and iy is true of all platforms.

NT / 2000 / 2003 server is = ServerNT

2k / xp client = Winnt

When the above reg key is checked HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions\ProductType

Gold star to ACalcutt

Link to comment
Share on other sites

  • 9 months later...

The thing that baffles me is that KiXtart can do this where as AutoIt can't determine on its own.

I think that there should be a macro like this:

@OSFullVer

==========

 

Returns one of the following values:

"Windows 95 A"

"Windows 95 B"

"Windows 98"

"Windows 98SE"

"Windows NT 4 Workstation"

"Windows NT 4 Server"

"Windows NT 4 Domain Controller"

"Windows ME"

"Windows 2000 Professional"

"Windows 2000 Server"

"Windows 2000 Domain Conroller"

"Windows XP Starter Edition"

"Windows XP Home Edition"

"Windows XP Professional"

"Windows XP Tablet Edition"

"Windows XP Media Center Edition"

"Windows XP Embedded"

"Windows XP Professional x64"

"Windows Whistler Server";XP Server, only exists if convert XP Pro to Server I believe

"Windows Server 2003"

"Windows Server 2003 Domain Controller"

"Windows Small Business Server 2003"

"Windows Storage Server 2003"

"Windows Server 2003 R2"

"Windows Server 2003 R2 Domain Controller"

"Windows Vista Home Basic"

"Windows Vista Home Premium"

"Windows Vista Ultimate"

"Windows Vista Business"

"Windows Vista Enterprise"

"Windows Server Longhorn"

"Windows Server Longhorn Domain Controller"

"Wine";Windows Emulator
[size="4"]YOU SHALL NOT PARSE!![/size]
Link to comment
Share on other sites

In fact...

I managed to make a UDF that kind of does this...

Problems outlined below:

_GetOS()
========

Issue A: If a 9x os is reported but not returned by @OSVersion then it attempts to use an NT-only struct, but with a condition (NT-only creates struct) then it reports that XP Pro is "Windows 9x".

Issue B: If the system is XP Pro, somehow it believes it is XP Starter. If the Starter code is commented out it believes the system is XP Tablet. :huh: 

Issue C: The original safe mode code [u]always[/u] returned True. Altered <> 0 to = (1 or 2)
[size="4"]YOU SHALL NOT PARSE!![/size]
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...