Page 1 of 1 1
Topic Options
#56606 - 2001-06-18 09:01 PM Excluding OS in Script
Anonymous
Unregistered


I am interesting in excluding by OS type where a script will be run. The reasoning behind my request is to exclude scripts running on any server environment. Any info would be appreciated.

JAS

Top
#56607 - 2001-06-18 09:05 PM Re: Excluding OS in Script
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Hi Josh and welcome to the board.

This bit of code should fit the bill. If not please post and I'm sure someone has the answer your looking for.

code:
IF @INWIN = 1
$SRVR = ReadValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions", "ProductType")
IF $SRVR<>"WinNT" ; System is not a Workstation so assume it is a Server
QUIT
ENDIF
ENDIF

NTDOC

Top
#56608 - 2001-06-19 12:04 AM Re: Excluding OS in Script
Fugazi Offline
Starting to like KiXtart

Registered: 2001-04-23
Posts: 142
Loc: Pace, Fl.
This is what I came up with to resolve this.

If $winnt = 1
$platformtype = ReadValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions", "ProductType")
If @ERROR = 0
If $platformtype = "ServerNT"
Goto scriptend
EndIf
EndIf
EndIf

------------------
Children are Nature's way of showing you what the world looks like at 3am.

_________________________
I haven't failed. I just found another way that did not work.

Top
#56609 - 2001-06-19 12:05 AM Re: Excluding OS in Script
Fugazi Offline
Starting to like KiXtart

Registered: 2001-04-23
Posts: 142
Loc: Pace, Fl.
If @INWIN = 1
$winnt = 1
EndIf

If @INWIN = 2
$win95 = 1
EndIf

Forgot this part of the script.

_________________________
I haven't failed. I just found another way that did not work.

Top
#56610 - 2001-06-19 05:21 AM Re: Excluding OS in Script
MCA Offline
KiX Supporter
*****

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

There are many versions of windows. For that reason we create some
code.
The result is not only the different between 95 or nt,
but it will return a $os variable with the value.

Our script is:

code:

IF (@inwin = 1)
$NT_mode="yes"
ELSE
$NT_mode="no"
ENDIF
;
$os=""
$os_dos=@dos
SELECT
CASE ($NT_mode = "yes") AND ($os_dos = "5.0") ; - Windows 2000 -
$os="W2K"
CASE ($NT_mode = "yes") ; - Windows NT -
$os="NT4"
CASE ($NT_mode <> "yes") AND ($os_dos = "4.90") ; - Windows ME -
$os="ME"
CASE ($NT_mode <> "yes") AND ($os_dos = "4.10") ; - Windows 98 -
$os="W98"
CASE ($NT_mode <> "yes") AND ($os_dos = "4.0") ; - Windows 95 -
$os="W95"
CASE 1
$os="???" ; - undetermined -
ENDSELECT
$os=LTRIM(RTRIM(substr($os+" ",1,3)))
;
? "os "+$os


Possible output: W2K, NT4, ME, W98, W95, or ???.
In your code you can you this variable.
f.e.
code:

SELECT
CASE ($os = "W2K")
; things to do for windows 2000
CASE ($os = "ME")
; things to do for windows ME
CASE 1
; things to do for all other windows versions.
ENDSELECT

For your server check you can use following code

code:

$os_product=ReadValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions","ProductType")
SELECT
CASE (@inwin = 1) AND ($os_product <> "WinNT") AND (@dos = "5.0") ; - Windows 2000 -
$server="W2K_Server"
CASE (@inwin = 1) AND ($os_product = "LANMANNT") ; - Windows NT -
$server="NT4_Domain_Controller"
CASE (@inwin = 1) AND ($os_product = "ServerNT") ; - Windows NT -
$server="NT4_Member_Server"
CASE 1
$server="no"
ENDSELECT


The variable $server contains no or the name of the server.

Greetings.

------------------
Site map:

_________________________
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
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
1 registered (Allen) and 363 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.051 seconds in which 0.022 seconds were spent on a total of 12 queries. Zlib compression enabled.

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