Paradox Posted September 16, 2005 Share Posted September 16, 2005 Hey guys,Been a couple days so that's a good thing... I'm back working on my SQL Server & Web Data Administrator installation package (again). Wound up getting to test it live the other day and everyone was relatively impressed about it. Did wind up having one minor glitch in it though; the machine that it was being run on was a Windows 2003 Server. I hadn't counted on the fact that to create virtual directories in 2003 is just slightly different than on XP Pro. I've gone through and re-written my script to make it semi-intelligent to the point that it will detect what OS version your running, but now here's the issue: The commands to create a virtual directory in 2000 Pro are different than how you can do the same thing in 2000 Server. Yes, I've already thought about using the @OSBuild routine to tell the different between the two, but the apparent problem with that is that 2000 Pro and 2000 Server have the same build numbers (2195) so I can't use that to dissern the two, and since @OSVersion is going to return the same info for both ("Win_2000") I can't use that either.Anyone have any ideas for what I can to to tell the difference between the two? Link to comment Share on other sites More sharing options...
SumTingWong Posted September 16, 2005 Share Posted September 16, 2005 Hey guys,The commands to create a virtual directory in 2000 Pro are different than how you can do the same thing in 2000 Server. Yes, I've already thought about using the @OSBuild routine to tell the different between the two, but the apparent problem with that is that 2000 Pro and 2000 Server have the same build numbers (2195) so I can't use that to dissern the two, and since @OSVersion is going to return the same info for both ("Win_2000") I can't use that either.Anyone have any ideas for what I can to to tell the difference between the two? Latest beta supports 2003. Check it out. Link to comment Share on other sites More sharing options...
Paradox Posted September 16, 2005 Author Share Posted September 16, 2005 Latest beta supports 2003. Check it out.nonono... I think you misunderstood... All I need my script to do is tell the difference between 2000 Pro and 2000 Server... I'm not too worried about the 2003 issue... I already have the command that needs to be run in that (2003)... There's 2 different commands that I have to run within the 2000 Pro and Server environments... that's why I need to have my script be able to tell the difference between Pro and Server. Link to comment Share on other sites More sharing options...
SumTingWong Posted September 16, 2005 Share Posted September 16, 2005 nonono... I think you misunderstood... All I need my script to do is tell the difference between 2000 Pro and 2000 Server... I'm not too worried about the 2003 issue... I already have the command that needs to be run in that (2003)... There's 2 different commands that I have to run within the 2000 Pro and Server environments... that's why I need to have my script be able to tell the difference between Pro and Server. The UDF below should give you what you want. You need latest beta for DllStruct stuff.For more info on the values returned, have a look hereexpandcollapse popup#include <Array.au3> Dim $aVersion = _GetVersionEx() _ArrayDisplay($aVersion, "") Func _GetVersionEx() #cs struct _OSVERSIONINFOEX { DWORD dwOSVersionInfoSize; DWORD dwMajorVersion; DWORD dwMinorVersion; DWORD dwBuildNumber; DWORD dwPlatformId; TCHAR szCSDVersion[128]; WORD wServicePackMajor; WORD wServicePackMinor; WORD wSuiteMask; BYTE wProductType; BYTE wReserved; } #ce Local $OSVERSIONINFOEX = "dword;dword;dword;dword;dword;char[128];short;short;short;byte;byte" Local $pVersionInfo Local $aDllRet Local $aVersion[9] $pVersionInfo = DllStructCreate($OSVERSIONINFOEX) If Not @error Then ConsoleWrite(DllStructGetSize($pVersionInfo) & @LF) DllStructSetData($pVersionInfo, 1, DllStructGetSize($pVersionInfo)) $aDllRet = DllCall("kernel32.dll", "int", "GetVersionEx", "ptr", DllStructGetPtr($pVersionInfo)) If Not @error And $aDllRet[0] <> 0 Then ; dwMajorVersion $aVersion[0] = DllStructGetData($pVersionInfo, 2) ; dwMinorVersion $aVersion[1] = DllStructGetData($pVersionInfo, 3) ; dwBuildNumber $aVersion[2] = DllStructGetData($pVersionInfo, 4) ; dwPlatformId $aVersion[3] = DllStructGetData($pVersionInfo, 5) ; szCSDVersion $aVersion[4] = DllStructGetData($pVersionInfo, 6) ; wServicePackMajor $aVersion[5] = DllStructGetData($pVersionInfo, 7) ; wServicePackMinor $aVersion[6] = DllStructGetData($pVersionInfo, 8) ; wSuiteMask $aVersion[7] = DllStructGetData($pVersionInfo, 9) ; wProductType $aVersion[8] = DllStructGetData($pVersionInfo, 10) EndIf DllStructDelete($pVersionInfo) EndIf Return $aVersion EndFunc Link to comment Share on other sites More sharing options...
djek Posted September 17, 2005 Share Posted September 17, 2005 (edited) from:Google Groups You must read in system register the following key:HKLM\System\CurrentControlSet\Control\ProductOptionsThe value of "WINNT" is for Windows NT WorkstationThe value of "SERVERNT" is for Windows NT Server (3.5 and higher )The value of "LANMAN" is for Windows NT Advanced Server ver 3.1It only works for NT and newer.I didn't test this, but sounds easy enough to distinguish a server from a workstationsee also Where Am I Running?Something like this:msgbox(0,"type",_producttype()) Func _producttype() $val=RegRead("HKLM\System\CurrentControlSet\Control\ProductOptions","ProductType") Select Case $val="WINNT" return "Workstation" Case $val="SERVERNT" return "Server" Case $val="LANMAN" return "AdvansedServer" Case $val="" return "prewinnt" Case Else return "unknown" EndSelect EndFunc(sorry, thedoes not indent) Edited September 17, 2005 by djek Link to comment Share on other sites More sharing options...
Paradox Posted September 19, 2005 Author Share Posted September 19, 2005 (edited) Just to let you all know, here's something along the exact lines of a solution for what I'm looking for: $pVersionInfo = DllStructCreate("byte") DllStructSetData($pVersionInfo, 1, DllStructGetSize($pVersionInfo)) $ret = DllCall("kernel32.dll", "int", "GetVersionEx", "ptr", DllStructGetPtr($pVersionInfo)) if Not $ret Then MsgBox(0,"DllCall Error","DllCall Failed") exit EndIf $WinProductType = DllStructGetData($pVersionInfo, 1) DllStructDelete($pVersionInfo) select case $WinProductType = 1 $platform = "Workstation" case $WinProductType = 2 $platform = "Domain Controller" case $WinProductType = 3 $platform = "Server" EndSelect msgbox(0, "OS Platform", "Platform : " & $platform) This SHOULD simply tell you if the machine that you're running on is a workstation, server, or domain controller. However, what's going on is I'm getting a DllCall Failure... Can anyone point out where my mistake is??? Thank you all though! The suggestions were of fantastic useage to me thus far!!! -Jay Edited September 19, 2005 by Paradox Link to comment Share on other sites More sharing options...
SumTingWong Posted September 19, 2005 Share Posted September 19, 2005 (edited) Just to let you all know, here's something along the exact lines of a solution for what I'm looking for:This SHOULD simply tell you if the machine that you're running on is a workstation, server, or domain controller. However, what's going on is I'm getting a DllCall Failure... Can anyone point out where my mistake is???Thank you all though! The suggestions were of fantastic useage to me thus far!!! -Jay See my code above. I believe you need to pass GetVersionEx the full OSVERSIONINFOEX struct.Oh and $ret is an array so you have to do If $ret[0] <> 0 Then....Here you go.Func _GetOSProductType() Local $OSVERSIONINFOEX = "dword;dword;dword;dword;dword;char[128];short;short;short;byte;byte" Local $pVersionInfo Local $aDllRet Local $sProductType $pVersionInfo = DllStructCreate($OSVERSIONINFOEX) If Not @error Then DllStructSetData($pVersionInfo, 1, DllStructGetSize($pVersionInfo)) $aDllRet = DllCall("kernel32.dll", "int", "GetVersionEx", "ptr", DllStructGetPtr($pVersionInfo)) If Not @error And $aDllRet[0] <> 0 Then ; wProductType $sProductType = DllStructGetData($pVersionInfo, 10) Select Case $sProductType = 1 $sProductType = "Workstation" Case $sProductType = 2 $sProductType = "Domain Controller" Case $sProductType = 3 $sProductType = "Server" EndSelect EndIf DllStructDelete($pVersionInfo) EndIf Return $sProductType EndFunc Edited September 19, 2005 by SumTingWong Link to comment Share on other sites More sharing options...
GaryFrost Posted September 19, 2005 Share Posted September 19, 2005 Here's something else that might be of interest to you. SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
Paradox Posted September 19, 2005 Author Share Posted September 19, 2005 See my code above. I believe you need to pass GetVersionEx the full OSVERSIONINFOEX struct.Oh and $ret is an array so you have to do If $ret[0] <> 0 Then....Here you go.Func _GetOSProductType() Local $OSVERSIONINFOEX = "dword;dword;dword;dword;dword;char[128];short;short;short;byte;byte" Local $pVersionInfo Local $aDllRet Local $sProductType $pVersionInfo = DllStructCreate($OSVERSIONINFOEX) If Not @error Then DllStructSetData($pVersionInfo, 1, DllStructGetSize($pVersionInfo)) $aDllRet = DllCall("kernel32.dll", "int", "GetVersionEx", "ptr", DllStructGetPtr($pVersionInfo)) If Not @error And $aDllRet[0] <> 0 Then ; wProductType $sProductType = DllStructGetData($pVersionInfo, 10) Select Case $sProductType = 1 $[b]sProductType = "Workstation" Case $sProductType = 2 $sProductType = "Domain Controller" Case $sProductType = 3 $sProductType = "Server" EndSelect EndIf DllStructDelete($pVersionInfo) EndIf Return $sProductType EndFuncDude... You kick ass! That works out PERFECTLY!!! Thank you so very much!!! God, you just made my day so much better, you have no idea! Link to comment Share on other sites More sharing options...
jefhal Posted September 19, 2005 Share Posted September 19, 2005 (edited) One more way to do it, courtesy of AutoIT Scriptomatic: ; Generated by AutoIt Scriptomatic ; Courtesy of SvenP ; Find AutoIT Scriptomatic at: http://www.autoitscript.com/forum/index.php?act=Attach&type=post&id=2329 $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" ;$strComputer = "localhost"; use this line for hardcoding computername ('localhost' for your machine) $strComputer = InputBox("Get System Name","Enter target System Name:"); use this line to enter any machine name $Output="" $Output = $Output & "Computer: " & $strComputer & @CRLF $Output = $Output & "==========================================" & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems $Output = $Output & "Caption: " & $objItem.Caption & @CRLF if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop $Output="" Next Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_OperatingSystem" ) Endif Edited September 19, 2005 by jefhal ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now