Page 1 of 1 1
Topic Options
#62001 - 2002-01-11 12:12 AM Determing an OS
tomfew Offline
Fresh Scripter
*****

Registered: 2001-05-15
Posts: 43
Loc: Pittsburgh, PA
Currently, we are pushing down front end program for our database down onto each users desktop. Now that we are running a mixed enviroment of WIN9X and W2K machines, we now have two different programs which correspond with the users OS.

How can I determine in the login script what OS the user is running so the correct front end database program is pushed to their desktop?

Here's what we are using right now:

IF INGROUP ("BFA2000W2K") = 1
$file1="i:\bfsprog 2000.mdb"
$file2=ReadValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","Desktop")
$file3=$file2+"\bfsprog 2000.mdb"
$file4=$file2+"\bfsprog.mdb"
$Result1 = GetFileTime($file1)
$Result2 = GetFileTime($file3)
$Result3 = Exist($file4)
;Deletes the OLD BFAPRODG file from the desktop
If $Result3 = 1
$t = "Deleting your old BFA Database File - Please wait..." GOSUB text
DEL $file4
Endif
;? "Desktop Database File: "+$result1+" Server Database File: "+$result2 ;Shows the file times on the login script
IF ($Result2 <> $Result1) ;Does File2 = File1?
$t = "Updating your BFA Database File - Please wait..." GOSUB text
COPY $file1 $file2
Else
$t = "You have the most recent BFA Database File..." GOSUB text
ENDIF
ENDIF

Thanks in advanced for your help.

Tom Few
Pittsburgh, PA

Top
#62002 - 2002-01-11 12:22 AM Re: Determing an OS
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
Hello Tom,

If only worried between NT and Win9x you can use this.

IF @INWIN = 1
;do your NT code here
ELSE
;do your Win9x code here
ENDIF

Top
#62003 - 2002-01-11 01:48 AM Re: Determing an OS
Anonymous
Unregistered


this is the one i wrote is work great for all OS try it you will like it

code:

:check_os

DIM subver
DIM type


SELECT
Case @inwin=1
$kernel="WinNT"
$type=ReadValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions","ProductType")
SELECT
Case @dos=5.0
$system="Win2k"

SELECT
Case $type="ServerNT"
$os_type="Server"
Case $type="WinNT"
$os_type="Professional"
ENDSELECT

Case @dos=4.0
$system="WinNT"
SELECT
Case $type="LANMANNT"
$os_type="Domain Controller"
Case $type="ServerNT"
$os_type="Member Server"
Case $type="WinNT"
$os_type="Workstation"
ENDSELECT

ENDSELECT

$svcpack=ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion","CSDVersion")

Case @inwin=2
$kernel="Win9x"
$subver=ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion","SubVersionNumber")

SELECT
Case @dos="???"
$system="WinME"
$os_type="A"

Case @dos="4.10"
$system="Win98"

SELECT
Case $subver=
$os_type="SE"
Case $subver="a"
$os_type="A"
ENDSELECT

Case @dos="4.0"
$system="Win95"

SELECT
Case $subver=" C"
$os_type="OSR2.5"
Case $subver=" B"
$os_type="OSR2"
Case $subver="a"
$os_type="A"
ENDSELECT

ENDSELECT

$svcpack=""
Case 1
$kernel="unknown"
$system="unknown"
$os_type="unknown"
$svcpack=""

ENDSELECT

;---------------------------
$report_entry = "Kernel type"
$report_value = $kernel
gosub "report"
;---------------------------
;---------------------------
$report_entry = "Operating System"
$report_value = $system + " " + $svcpack
gosub "report"
;---------------------------
;---------------------------
$report_entry = "OS type"
$report_value = $os_type
gosub "report"
;---------------------------

; downward compatibility for older scripts
$os = ""
$win_9x = ""
If @INWIN=2
Select
Case @DOS = "4.0"
$os = "Windows 95"
$win_9x = "yes"
Case @DOS = "4.10"
$os = "Windows 98"
$win_9x = "yes"
EndSelect
Endif

Return



Top
#62004 - 2002-01-11 02:26 AM Re: Determing an OS
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
Well, if you do want a full on OS script there are a couple out there.

I like this one from MCA which works with KiXtart v3.6x

code:
; http://home.wanadoo.nl/scripting 
; http://home.wanadoo.nl/scripting/download/os.kix
; IF setconsole("hide")
; ENDIF
;
; NT/95 calculates os - Kixtart 3.62, 3.63, 4.00
;
; (c) scripting@wanadoo.nl - 2000, 2001
;
; vs 2.09 - program (calculates OS version with service pack)
;
; 1.00 (20000715) original version
; 2.00 (20010330) - add "windows ME"
; - returns $os + $os_type values
; 2.01 (20010401) - kixtart 2001 beta1 compliancy
; 2.02 (20010405) - remove cutting $os value
; 2.03 (20010701) - add "windows XP beta" + "windows 2000 terminal server"
; (input by NTDOC)
; 2.04 (20010725) - minor fix
; 2.05 (20011115) - fix "windows 2000 terminal server" was presented as
; "windows 2000 server"
; (input by NTDOC)
; 2.06 (20011115) - add "windows NT terminal server"
; (input by Mike Wade)
; 2.07 (20011115) - add "windows XP terminal server"
; - improvement terminal server
; - suppress SetConsole("hide")
; 2.08 (20011201) - add "windows XP home" (input by Mike Wade)
; 2.09 (20011201) - incorrect "service pack" result by "Windows2000 SP3, RC 3.51"
; (input by NTDOC)
;
$prgm_version="2.09"

IF (@inwin = 1)
$NT_mode="yes"
ELSE
$NT_mode="no"
ENDIF

$os=""
$os_dos=@dos
$os_product=ReadValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions","ProductType")
$os_productSuite=ReadValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions","ProductSuite")
$os_service_pack=""
$os_subversion=ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion","SubVersionNumber")
SELECT
CASE ($NT_mode = "yes") AND ($os_product <> "WinNT") AND ($os_dos = "5.1") AND (Instr($os_productSuite,"Terminal Server") <> 0)
$os="XP_Terminal_Server"
CASE ($NT_mode = "yes") AND ($os_product <> "WinNT") AND ($os_dos = "5.1") ; - Windows XP Server
$os="XP_Server"
CASE ($NT_mode = "yes") AND ($os_product = "WinNT") AND ($os_dos = "5.1") AND ($os_productSuite = "personal") ; - Windows XP Home
$os="XP_Home"
CASE ($NT_mode = "yes") AND ($os_product = "WinNT") AND ($os_dos = "5.1") ; - Windows XP Professional
$os="XP_Professional"
CASE ($NT_mode = "yes") AND ($os_product <> "WinNT") AND ($os_dos = "5.0") AND (Instr($os_productSuite,"Terminal Server") <> 0)
$os="W2K_Terminal_Server"
CASE ($NT_mode = "yes") AND ($os_product <> "WinNT") AND ($os_dos = "5.0") ; - Windows 2000 -
$os="W2K_Server"
CASE ($NT_mode = "yes") AND ($os_product = "WinNT") AND ($os_dos = "5.0")
$os="W2K_Professional"
CASE ($NT_mode = "yes") AND ($os_product = "LANMANNT") ; - Windows NT -
$os="NT4_Domain_Controller"
CASE ($NT_mode = "yes") AND ($os_product = "ServerNT") AND (Instr($os_productSuite,"Terminal Server") <> 0)
$os="NT4_Terminal_Server"
CASE ($NT_mode = "yes") AND ($os_product = "ServerNT")
$os="NT4_Member_Server"
CASE ($NT_mode = "yes") AND ($os_product = "WinNT")
$os="NT4"
CASE ($NT_mode <> "yes") AND (@dos = "4.90")
$os="ME"
CASE ($NT_mode <> "yes") AND ($os_dos = "4.10") AND (INSTR(LCASE($os_subversion),"c") <> 0) ; - Windows 98 -
$os="W98c"
CASE ($NT_mode <> "yes") AND ($os_dos = "4.10") AND (INSTR(LCASE($os_subversion),"b") <> 0)
$os="W98b"
CASE ($NT_mode <> "yes") AND ($os_dos = "4.10") AND (INSTR(LCASE($os_subversion),"a") <> 0)
$os="W98a"
CASE ($NT_mode <> "yes") AND ($os_dos = "4.10")
$os="W98"
CASE ($NT_mode <> "yes") AND ($os_dos = "4.0") AND (INSTR(LCASE($os_subversion),"c") <> 0) ; - Windows 95 -
$os="W95c"
CASE ($NT_mode <> "yes") AND ($os_dos = "4.0") AND (INSTR(LCASE($os_subversion),"b") <> 0)
$os="W95b"
CASE ($NT_mode <> "yes") AND ($os_dos = "4.0") AND (INSTR(LCASE($os_subversion),"a") <> 0)
$os="W95a"
CASE ($NT_mode <> "yes") AND ($os_dos = "4.0")
$os="W95"
CASE 1
$os="???" ; - undetermined -
ENDSELECT
;
$os_service_pack=""
SELECT
CASE ($NT_mode = "yes") AND ($os_dos = "5.1") ; - Windows XP
$os_service_pack=ReadValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion","BuildLab")
IF (len($os_service_pack) <> 0)
$os_service_pack=LTRIM(RTRIM($os_service_pack))
$os=substr($os,1,3)+"_"+LTRIM(RTRIM($os_service_pack))
ENDIF
CASE ($NT_mode = "yes") AND ($os_dos <> "5.1") ; Windows NT4 + W2K
$os_service_pack=ReadValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion","CSDVersion")
IF (len($os_service_pack) <> 0)
$os_service_pack=LTRIM(RTRIM($os_service_pack))
IF (instr($os_service_pack,",") <> 0)
$os=substr($os,1,3)+"_"+substr($os_service_pack,instr($os_service_pack,",")-1,1)
ELSE
$os=substr($os,1,3)+"_"+substr($os_service_pack,len($os_service_pack),1)
ENDIF
ENDIF
CASE 1
; Windows 95, 98 + ME
ENDSELECT
;
$os_type=""
$os_dos=@dos
SELECT
CASE ($NT_mode = "yes") AND ($os_dos = "5.1") ; - Windows XP -
$os_type="XP"
CASE ($NT_mode = "yes") AND ($os_dos = "5.0") ; - Windows 2000 -
$os_type="W2K"
CASE ($NT_mode = "yes") ; - Windows NT -
$os_type="NT4"
CASE ($NT_mode <> "yes") AND ($os_dos = "4.90") ; - Windows ME -
$os_type="ME"
CASE ($NT_mode <> "yes") AND ($os_dos = "4.10") ; - Windows 98 -
$os_type="W98"
CASE ($NT_mode <> "yes") AND ($os_dos = "4.0") ; - Windows 95 -
$os_type="W95"
CASE 1
$os_type="???" ; - undetermined -
ENDSELECT
$os_type=LTRIM(RTRIM(substr($os_type+" ",1,3)))
;
IF ($NT_mode = "yes")
? "$$os "+$os ; <--- $os_type + service pack code
? "$$os_type "+$os_type
? "$$os_service_pack "+$os_service_pack
ELSE
? "$$os "+$os ; <--- $os_type + service pack code
? "$$os_type "+$os_type
ENDIF


[ 11 January 2002: Message edited by: NTDOC ]

Top
#62005 - 2002-01-11 04:04 AM Re: Determing an OS
bleonard Offline
Seasoned Scripter
*****

Registered: 2001-01-19
Posts: 581
Loc: Chicago, IL
Well, I guess I'll post my variation on MCA's script, including identifying WinNT Service Pack 6a installations.

Bill

code:

; REM ** Set reusable variables for registry keys, O/S values
SELECT
CASE (@INWIN = 1)
$HKLMSS = READVALUE ("HKEY_LOCAL_MACHINE\SYSTEM\Select", "Current")
$CurCtrStr = "ControlSet00"+$HKLMSS
$HKLMSCCS = "HKEY_LOCAL_MACHINE\System\$CurCtrStr"
$HKLMSMWNTCV = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion"
$OSSui = UCASE (READVALUE ("$HKLMSCCS\Control\ProductOptions", "ProductSuite"))
$OSTyp = UCASE (READVALUE ("$HKLMSCCS\Control\ProductOptions", "ProductType"))
$OSVer = READVALUE ("$HKLMSMWNTCV", "CurrentVersion")
CASE (1)
$HKLMSMWCV = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion"
$OSSvc = LTRIM (RTRIM (UCASE (READVALUE ("$HKLMSMWCV", "SubVersionNumber"))))
$OSVer = READVALUE ("$HKLMSMWCV", "VersionNumber")
ENDSELECT


; REM ** Determine O/S, and O/S Level for Win9x boxes
SELECT
CASE (@DOS >= 5.1) $OS = "WinXP"
CASE (@DOS >= 5.0) $OS = "Win2K"
CASE (@DOS >= 4.0) AND (@INWIN = 1) $OS = "WinNT"
CASE ($OSVer >= "4.90.3000") $OS = "WinME" $OSLvl = "OEM"
CASE ($OSVer >= "4.10.2222") $OS = "Win98" $OSLvl = "SE"
CASE ($OSVer >= "4.10.1998") $OS = "Win98" $OSLvl = "OEM"
CASE (($OSVer >= "4.03.1214") AND ($OSSvc = "C")) $OS = "Win95" $OSLvl = "SR 2.5"
CASE (($OSVer >= "4.03.1212") AND ($OSVer =< "4.03.1214")) $OS = "Win95" $OSLvl = "SR 2.1"
CASE ($OSVer >= "4.00.1111") $OS = "Win95" $OSLvl = "SR 2"
CASE (($OSVer >= "4.00.950") AND ($OSSvc = "A")) $OS = "Win95" $OSLvl = "SP 1"
CASE ($OSVer >= "4.00.950") $OS = "Win95" $OSLvl = "OEM"
CASE (1)
$AdmErr = $Err+1
$OSAbv = "Unknown"
GOTO EndScript
ENDSELECT


; REM ** Determine WinXP/2K/NT Server/Workstation installed Service Pack level
IF (@INWIN = 1)
; REM ** Determine Service Pack level
$RC = READVALUE ("$HKLMSMWNTCV\Hotfix\Q246009", "Installed") ; REM ** Check if running WinNT SP6a
SELECT
CASE ($OS = "WinNT") AND ($RC = "1") $OSSvc = "Service Pack 6a" ; REM ** See http://www.microsoft.com/ntserver/support/faqs/sp6faq.asp (2001.12.26)
CASE ($OS = "WinXP") $OSSvc = LTRIM (RTRIM (READVALUE ("$HKLMSMWNTCV", "BuildLab")))
CASE (1) $OSSvc = LTRIM (RTRIM (READVALUE ("$HKLMSMWNTCV", "CSDVersion")))
ENDSELECT


; REM ** Determine WinXP/2K/NT Server/Workstation role
SELECT
CASE (INSTR ($OSSui, "TERMINAL SERVER") <> 0) $OSLvl = "Terminal" ; REM ** WinXP/2K/NT Terminal Server
CASE (INSTR ($OSSui, "ENTERPRISE") <> 0) $OSLvl = "Enterprise" ; REM ** WinNT Enterprise Server
CASE (INSTR ($OSTyp, "LANMANNT") <> 0) $OSLvl = "DomainController" ; REM ** WinNT Domain Controller
CASE (INSTR ($OSTyp, "SERVERNT") <> 0) $OSLvl = "MemberServer" ; REM ** WinNT Member Server
CASE (INSTR ($OSTyp, "WINNT") = 0) $OSLvl = "Server" ; REM ** Win2K Server (Domain/Member)
CASE (INSTR ($OSSui, "PERSONAL") <> 0) $OSLvl = "Home" ; REM ** WinXP Home Edition
CASE (INSTR ($OSTyp, "WINNT") <> 0) AND (@DOS >= 5.0) $OSLvl = "Pro" ; REM ** WinXP/2K Professional
CASE (INSTR ($OSTyp, "WINNT") <> 0) AND (@DOS >= 4.0) $OSLvl = "Wksta" ; REM ** WinNT Workstation
CASE (1)
$AdmErr = $Err+1
$OSLvl = "Unknown"
GOTO EndScript
ENDSELECT
ENDIF


[ 11 January 2002: Message edited by: bleonard ]

[ 11 January 2002: Message edited by: bleonard ]

Top
#62006 - 2002-01-11 11:34 AM Re: Determing an OS
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
Hi Bill,

I too have modified MCA script to find SP6a after reading your information. I did not want to post my variation though. I sent email to MCA to see if he wanted to modify his original code or not. I have also found a couple minor issues on what the real names are. i.e. Windows 2000 Advanced Server is actually Enterprise Terminal Server, and normal Windows 2000 Server is just Terminal Server.

I modify the wording to SP instead of _ that MCA has and I use the "full" os name description instead of the trimmed 4 character name used in original code.

I do love his script though. Very cool and has worked great for a while now for me in both versions of KiX. He also modifies it periodically to incorporate changes or ideas as requested. Not everyone has moved onto the new KiX 4.01 yet. I'm a little reluctant to, since I've been told I can only use it for a few months more. Then I have to start using WSH.

Thanks again for your ideas and submissions Bill. And thanks MCA for your original code.

Top
#62007 - 2002-01-11 04:04 PM Re: Determing an OS
Corky Offline
Fresh Scripter

Registered: 2002-01-11
Posts: 13
Hi Guys

Is it me or are people trying to be overly complicated with scripts. Why not use the @ProductType macro vor OS version and the @CSD macro for service pack determination. I know these only work in V 4 though ??


quote:
Surfs Up!

Top
#62008 - 2002-01-11 07:53 PM Re: Determing an OS
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
Hello Corky,

Yes, you hit it on the nail as I mentioned in my post already. A lot of users are still using v3.6x Version 4 has only recently been released to a level where most would agree is the better version to use. It was released a while back, but unfortunately had some issues that some users also did not want to switch over to the new version until it was fixed. Even now there is some kind of DACL problem that is supposed to have either a fix or a work around in a beta version that is being tested.

With that said, I think there are a lot of users using v4.01 but don't forget many have been using 3.6x for a long time and have some rather large scripts that would need to be thouroughly tested before going on to a new version. That is a large task also. These os version scripts have been around a while now and work quite well.

Also, not all companies are willing or wanting to move to the "latest, greatest" software until it has been out and tested for a while... ie. they want the bugs worked out before they use it. They don't want to be the test pilot for the program.

For now I think you will continue to see this type of code both posted and requested.

Top
#62009 - 2002-01-11 08:21 PM Re: Determing an OS
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

During the upgrade of os.kix we had temporary some problems with verifi-
cation of incorporated code. Not all environments could be tested with the new
code.
Currently we are working to new versions. OS.KIX will transfered to two separate
versions. First one will return the complete os information. The second one will
only return the short name of os (f.e. NT4, W2K, XP, W95).

With little modification both versions can be transfered to UDF functions. Possi-
ble we will put those versions as an UDF on the board.

The input from NTDOC, bleonard and other persons are always welcome.
greetings.

_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#62010 - 2002-01-11 11:48 PM Re: Determing an OS
tomfew Offline
Fresh Scripter
*****

Registered: 2001-05-15
Posts: 43
Loc: Pittsburgh, PA
Thank you for all of you help!

Tom Few
Pittsburgh, PA

Top
Page 1 of 1 1


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

Who's Online
0 registered and 1167 anonymous users online.
Newest Members
BeeEm, min_seow, Audio, Hoschi, Comet
17882 Registered Users

Generated in 0.134 seconds in which 0.063 seconds were spent on a total of 11 queries. Zlib compression enabled.

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