I need a simple script that will work on NT, XP, and 2000 machines that will
simply return the OS version, basically what I have is a multiple OS (NT,
XP, 2K) enviroment, and I want to add into the login script a script that
will retrieve the OS, I can do the rest into getting it into a SQL DB..


Thanks!!

Re: Script that will work on NT machines to grab OS version by Joseph

Joseph
Tue Jul 15 16:28:13 CDT 2003

You can use GetType.exe to determine the OS type. Here's the article from
MS.
http://tinyurl.com/h1ck

-josephc



Re: Script that will work on NT machines to grab OS version by Excalibur

Excalibur
Wed Jul 16 06:30:59 CDT 2003

here is a sub that works. I log all the stuff I install on a users system so
it has some stuff in it you wouldn't need probably. Oh the If statements
have to do with variables I set to yes or no for each operating system, That
way if a user tries to install it on something I don't want it on it stops
the script.

Have fun


sub OSys()
Dim tempOsys, Build, ver
Set WshShell = Wscript.CreateObject("Wscript.Shell")
Err.Clear
On Error Resume Next
ver= WSHShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\CurrentVersion")
Build =WSHShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\CurrentBuildNumber")
If Err <> 0 Then
ver=
WSHShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersi
on\Version")
Build
=WSHShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVers
ion\VersionNumber")
End if
err.clear : On Error GoTo 0
Select Case ver
Case "Windows 95"
tempOSys="win95"
If Win95 ="NO" Then
InstallLog.WriteLine("Detected Windows Version: "& tempOsys& ";
Package is not available for this OS: "& Win95 )
MsgBox "This Package was not written for the Windows 95 Operating
system", vbsystemmodal + vbinformation, "Message from IT"
InstallError = tempOSys
wscript.quit
End if
Case "5.0"
tempOSys ="w2k"
If Win2000 ="NO" Then
InstallLog.WriteLine ("Detected Windows Version: "& tempOsys& ";
Package is not available for this OS: "& Win2000)
MsgBox "This Package was not written for the Windows 2000 Operating
system", vbsystemmodal + vbinformation, "Message from IT"
InstallError = tempOSys
wscript.quit
End if
Case "5.1"
tempOSys = "wxp"
If WinXP ="NO" Then
InstallLog.WriteLine("Detected Windows Version: "& tempOsys& ";
Package is not available for this OS: "& WinXP )
MsgBox "This Package was not written for the Windows XP Operating
system", vbsystemmodal + vbinformation, "Message from IT"
InstallError = tempOSys
wscript.quit
End if
Case "4.0"
tempOSys = "wnt"
If WinNT ="NO" Then
InstallLog.WriteLine("Detected Windows Version: "& tempOsys& ";
Package is not available for this OS: "& WinNT )
MsgBox "This Package was not written for the Windows NT Operating
system", vbsystemmodal + vbinformation, "Message from IT"
InstallError = tempOSys
wscript.quit
End if
End Select

End sub
"JC" <Josh@Network-Medics.Com> wrote in message
news:erXGeBwSDHA.560@TK2MSFTNGP10.phx.gbl...
> I need a simple script that will work on NT, XP, and 2000 machines that
will
> simply return the OS version, basically what I have is a multiple OS (NT,
> XP, 2K) enviroment, and I want to add into the login script a script that
> will retrieve the OS, I can do the rest into getting it into a SQL DB..
>
>
> Thanks!!
>
>



Re: Script that will work on NT machines to grab OS version by Robert

Robert
Wed Jul 16 07:21:05 CDT 2003

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSettings = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colSettings
Wscript.Echo "OS Name: " & objOperatingSystem.Name
Next

--
Sorry, I am no longer including my e-mail address as I am getting to much
spam. I really have no desire to enlarge "it" by three inches, that is even
if I get e-mailed 10 times a day from different e-mail addresses so I can't
block it.
Besides I finally came to believe what others have said, if you have a
question, you should ask the group as others might benefit from it. Anyone
on the group who I converse with off topic or on the side, can easily find
my e-mail address.


"JC" <Josh@Network-Medics.Com> wrote in message
news:erXGeBwSDHA.560@TK2MSFTNGP10.phx.gbl...
> I need a simple script that will work on NT, XP, and 2000 machines that
will
> simply return the OS version, basically what I have is a multiple OS (NT,
> XP, 2K) enviroment, and I want to add into the login script a script that
> will retrieve the OS, I can do the rest into getting it into a SQL DB..
>
>
> Thanks!!
>
>



Re: Script that will work on NT machines to grab OS version by Ace

Ace
Thu Aug 07 14:59:07 CDT 2003


Originally posted by Joseph Carlisle
> You can use GetType.exe to determine the OS type. Here's the
> article from
> MS.
> http://tinyurl.com/h1ckhttp://tinyurl.com/h1ck
>
> -josephc


I have been following this, as I need to do the same thing. The gettype
utility version 4.0 only detects NT, 2000 (and their roles), and the
newest version apparently only detects Windows XP & Windows 2003. Is
there not a version or similar util that can detect ALL windows versions
(NT thru 2003)? I assume there must be a new gettype version that
includes the error codes for all these version, but cannot find it.
please advise. Thank you.

AR

--
Posted via http://dbforums.com

Re: Script that will work on NT machines to grab OS version by Jack

Jack
Thu Aug 07 16:00:19 CDT 2003

This will only work on the XP and W2K machines but that's all you need.
Just add error handling that will tell you that the machine is NT if the
script doesn't complete with 0.


Set dtmConvertedDate = CreateObject("WbemScripting.SWbemDateTime")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
Wscript.Echo "Caption: " & objOperatingSystem.Caption
Wscript.Echo "Version: " & objOperatingSystem.Version
Next


"Ace" <member35260@dbforums.com> wrote in message
news:3214813.1060286426@dbforums.com...
>
> Originally posted by Jc
> > I need a simple script that will work on NT, XP, and 2000 machines
> > that will
> > simply return the OS version, basically what I have is a
> > multiple OS (NT,
> > XP, 2K) enviroment, and I want to add into the login script a
> > script that
> > will retrieve the OS, I can do the rest into getting it into a
> > SQL DB..
> >
> >
> > Thanks!!
>
> I have been following this, as I need to do the same thing. The gettype
> utility version 4.0 only detects NT, 2000 (and their roles), and the
> newest version apparently only detects Windows XP & Windows 2003. Is
> there not a version or similar util that can detect ALL windows versions
> (NT thru 2003)? I assume there must be a new gettype version that
> includes the error codes for all these version, but cannot find it.
> please advise. Thank you.
>
> AR
>
> --
> Posted via http://dbforums.com