cjutting
(Fresh Scripter)
2013-10-08 10:05 PM
Best Way to Capture OS

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


Glenn BarnasAdministrator
(KiX Supporter)
2013-10-09 12:38 AM
Re: Best Way to Capture OS

You're funny looking! ;\)

Glenn BarnasAdministrator
(KiX Supporter)
2013-10-09 12:39 AM
Re: Best Way to Capture OS

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


cjutting
(Fresh Scripter)
2013-10-09 02:40 PM
Re: Best Way to Capture OS

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?


cjutting
(Fresh Scripter)
2013-10-09 03:41 PM
Re: Best Way to Capture OS

Nevermind. After getting caffeinated I'm good

Glenn BarnasAdministrator
(KiX Supporter)
2013-10-09 03:53 PM
Re: Best Way to Capture OS

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


cjutting
(Fresh Scripter)
2013-10-09 06:26 PM
Re: Best Way to Capture OS

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