"Bevan Houchen" <bevan....@xtra.co.nz> wrote in message
news:uDfhofU...@cppssbbsa02.microsoft.com...
> Is there a sure fire way of detecting the operating system and version that
> a script is running on ? I need to determine nt4 vs win2000 vs 95 vs 98.
There are two steps:
1.) Determine if it's Win9x, or WinNT/2K
Check for the environment variable "OS" (%OS%).
If it doesn't exists then you're working with Win9x,
if it does exist and it's "Windows_NT" then it's
WinNT/2K.
2.) If it's Win9x, check the registry:
HKLM\Software\Microsoft\Windows\CurrentVersion\CurrentVersion I believe.
I may be wrong, but it's something close to this
I believe Win95 is 4.00.1995 - 4.1.xxxx
Win98 is 4.1.xxxx or something similar
WinME is 4.5 I believe. I may be off on these, someone please correct
me.
If it's WinNT, check the registry:
HKLM\Software\Microsoft\WIndows NT\CurrentVersion\CurrentVersion
Build number is CurrentVersion\CurrentBuildNumber, service pack
version is CurrentVersion\CSDVersion
NT 4.0: CurrentVersion = 4.0
Win2K : CurrentVersion = 5.0
-Chad
Thanks.
"Chad Myers" <cmy...@NOSPAM.austin.rr.com> wrote in message
news:#IEejmUO...@cppssbbsa02.microsoft.com...
>
> "Bevan Houchen" <bevan....@xtra.co.nz> wrote in message
> news:uDfhofU...@cppssbbsa02.microsoft.com...
> > Is there a sure fire way of detecting the operating system and version
that
> > a script is running on ? I need to determine nt4 vs win2000 vs 95 vs 98.
>
Function GetOS()
If bDebug then wscript.echo "FUNCTION: GETOS"
Dim strOS
On Error Resume Next
Err.Clear
strOS=oShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions\ProductType")
If Hex(err)="80070002" Then
Err.Clear
strOS=oShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\VersionNumber")
If err<> 0 Then
GetOS=Null
Exit Function
End if
End If
Select Case strOS
Case "LanmanNT"
GetOS="NTD"
Case "ServerNT"
GetOS="NTS"
Case "WinNT"
GetOS="NTW"
Case "4.00.950"
GetOS="95A"
Case "4.00.1111"
GetOS="95B"
Case "4.10.1998"
GetOS="98"
Case "4.10.2222"
GetOS="98SE"
End Select
End Function
--
Michael Harris
Microsoft.MVP.Scripting
--
"Bevan Houchen" <bevan....@xtra.co.nz> wrote in message
news:OBrp2xU...@cppssbbsa02.microsoft.com...