Page 1 of 1 1
Topic Options
#207890 - 13/10/08 10:05 PM Best Way to Capture OS
cjutting Offline
Fresh Scripter

Registered: 10/02/05
Posts: 40
Loc: IA
We have a mix of XP, Windows 7 and Citrix. I'm trying to capture what the OS is so we can run specific things against desktop OS and server OS for Citrix

. I thought I had this little bit of code working, but after working with it some more turns out I don't and I'm not seeing where I went wrong. On Server 2008 it still runs the commands that I want to run against XP or Windows 7. The @ProductType does return Windows Serve 2008 R2 when ran.

 Code:
Select

	Case @PRODUCTTYPE = "Windows XP Professional" Or "Windows XP Professional Tablet PC" Or "Windows 7 Professional Edition"
		Stuff For PCs Only

	Case @PRODUCTTYPE = "Windows Server 2003" Or "Windows Server 2003 R2" Or "Windows Server 2008" Or "Windows Server 2008 (R2)"
		Stuff for Servers Only
		
EndSelect


Hopefully this is dumb and someone can point it out. Feel free to make fun of me freely

Top
#207894 - 13/10/09 12:38 AM Re: Best Way to Capture OS [Re: cjutting]
Glenn Barnas Moderator Offline
KiX Supporter
*****

Registered: 03/01/28
Posts: 4194
Loc: New Jersey
You're funny looking! ;\)
_________________________
Visit the Inno-Tech web site for Kix tools/UDFs
Actually I am a Rocket Scientist! \:D

Top
#207895 - 13/10/09 12:39 AM Re: Best Way to Capture OS [Re: Glenn Barnas]
Glenn Barnas Moderator Offline
KiX Supporter
*****

Registered: 03/01/28
Posts: 4194
Loc: New Jersey
Oh - you probably want an answer, too..

This is what I use in my KInstall utility:
 Code:
; ======================================================================
; IDENTIFICATION OF O/S
; determine the O/S installed & announce the findings..
;
$OSver= @DOS						; O/S Version
$fWS = 0
If Not InStr(@PRODUCTTYPE, 'Server') Or InStr(@PRODUCTTYPE, 'Controller')
  $fWS = 1						; set the Workstation flag
EndIf

$ = Split(@PRODUCTTYPE, ' ')
; accommodate old versions of Kix that called 2008 "Longhorn"
If InStr($[2], 'Longhorn')
  $[1] = '2008'
EndIf
$SYSID = IIf($[1] = 'Server', 'WIN' + $[2], 'WIN' + $[1])


; show data
'PType: ' @PRODUCTTYPE ?
'OSVer: ' $OSver ?
'SysID: ' $SysID ?
'   WS: ' $fWS ?
The SysID is Win(version), like Win2008, Win7, WinXP, etc.. The $fWS is true on Workstation class machines, so (heaven forbid) if you have Windows 2000 systems, the $SysID will be Win2000 and $fWS will be true on a workstation and false on a server.

Glenn
_________________________
Visit the Inno-Tech web site for Kix tools/UDFs
Actually I am a Rocket Scientist! \:D

Top
#207898 - 13/10/09 02:40 PM Re: Best Way to Capture OS [Re: Glenn Barnas]
cjutting Offline
Fresh Scripter

Registered: 10/02/05
Posts: 40
Loc: IA
Glen.

You are a gentleman among gentlemen!

So then you've found the OS, then your use your variables are you using an IF or Select/Case to do the rest of your work?


Edited by cjutting (13/10/09 03:27 PM)

Top
#207900 - 13/10/09 03:41 PM Re: Best Way to Capture OS [Re: cjutting]
cjutting Offline
Fresh Scripter

Registered: 10/02/05
Posts: 40
Loc: IA
Nevermind. After getting caffeinated I'm good
Top
#207901 - 13/10/09 03:53 PM Re: Best Way to Capture OS [Re: cjutting]
Glenn Barnas Moderator Offline
KiX Supporter
*****

Registered: 03/01/28
Posts: 4194
Loc: New Jersey
Yeah - for clarity of the post, though, I basically run through a Select/Case process on this.
 Code:
Select
 Case $SysID = 'Win2000'
  If $fWS
    ; workstation stuff..
  Else
    ; server stuff..
  EndIf
 Case $SysID = 'WinXP'
  ; XP stuff
 Case $SysID = 'Win2003'
   Server 2003 stuff..
; and so on...
EndSelect
Only NT and Win2000 need to rely on the $fWS value. You can also focus on just workstation or just server processes.

Glenn
_________________________
Visit the Inno-Tech web site for Kix tools/UDFs
Actually I am a Rocket Scientist! \:D

Top
#207903 - 13/10/09 06:26 PM Re: Best Way to Capture OS [Re: Glenn Barnas]
cjutting Offline
Fresh Scripter

Registered: 10/02/05
Posts: 40
Loc: IA
Even Simpler Yet:

 Code:
Select
				
	Case $fWS = 1
		? "Running TrackIT Machine Audit"
		run "\\IT-MGMT\TRACKIT\Audit.exe"
		
		
		call "@scriptdir\PCPrinters.kix"
		
	Case #fWS = 0
		; Nothing to See Here Move On
		
		;call CitrixPrinters.kix
		
EndSelect

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Chris S., Glenn Barnas, ShaneEP, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Shawn) and 90 anonymous users online.
Newest Members
B1GHawkeyes, GeoHamm, register, Marcus_Dunne, stuvwx656262
17397 Registered Users

Generated in 0.298 seconds in which 0.057 seconds were spent on a total of 13 queries. Zlib compression enabled.

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