|
|
|||||||
Hi Kixtart Community in our company do we use for a logon script kixtart. I want make for the Windows 8 and later Users some changes different then the Windows 7 Users. My Idea was like this. Code: $osversion = @DOS if $osversion >= 6.2 ? "Do something for Windows 8 and later." else ? "Do Something for Windows 7 and earlier." endif this compare doesn't work every time is this compare true. When I set the variable "$osversion" for example Code: $osversion = 5.2 I think the problem is something wrong with the data type that I get from the "@DOS" command. Can you give me a tip to fix this problem. regards christian |
||||||||
|
|
|||||||
Kixtart is not strongly typed. Try adding in some error checking: Code: if @DOS >= 6.2 ? @SERROR ? "Do Windows 8 stuff" else ? @SERROR ? "Do Windows 7 stuff" endif See what that gives you. |
||||||||
|
|
|||||||
Try using this: Code: $osversion = ReadValue("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion","CurrentVersion") |
||||||||
|
|
|||||||
You can force a numeric compare with $Ver = Val(@DOS), or $Ver = 1.0 * @DOS. In the second form, Kix sees a decimal number and converts the entire process to that format based on the first item referenced. Multiplying by 1.0 doesn't change the value but forces Kix to use precision math. @DOS might return a version string, which will throw things off. Glenn |
||||||||
|
|
|||||||
Taking a minute to run "VarTypeName(@DOS)" confirms that it does return a string. This is the reason for inconsistent results. In my Universal Login Script, I have a global var that holds the OS Version as a number, available to other functions that might need it. Glenn |
||||||||
|
|
|||||||
Thanks glenn with the function val() works now. thank you for your fast response. regards christian |
||||||||
|
|
|||||||
Sorry with val it doesn't work too. with the "1.0 *" I get just the first digit. i think this is a problem about the "," char. in Switzerland we have comma separated not with a point. @arend With your solution i have the same problem with "@DOS" now I make the check with @PRODUCTTYPE Code: if @PRODUCTTYPE == "Windows 7 Enterprise Edition" ;? "Do Something for Windows 7" else ;? "Do something for other Windows" endif in this way I don' t have the flexibility with a numeric variable. but on this way I can make different between the Windows 7 and the others. thanks for your help regards christian |
||||||||
|
|
|||||||
Please post your code for the 1.0* code, there is probably something amiss. As for the other code, this will likely cover your bases a bit better. Code: Select Case instr(@producttype,"Windows 7") ;do stuff Case instr(@producttype,"Windows 8") ;do stuff Case 1 ? "OS not covered" Endselect |
||||||||
|
|
|||||||
Did you try 1,0 * @DOS? You need to be consistent with the regional settings. The multiplication by 1 doesn't change the value, and specifying a decimal point forces the value to be a real number, not an integer. Glenn |
||||||||
|
|
|||||||
Personally I use code similar to Allen's: Code: Select Case Left(@ProductType,9) = "Windows 7" ;do stuff Case Left(@ProductType,9) = "Windows 8" ;do stuff Case Left(@ProductType,10) = "Windows 10" ;do stuff Case 1 ? "OS not covered" Endselect |
||||||||
|
|
|||||||
The following table summarizes the most recent operating system version numbers. Operating system Version number Windows 10= 10.0* Windows Server 2019= 10.0* Windows Server 2016= 10.0* Windows 8.1= 6.3* Windows Server 2012 R2= 6.3* Windows 8= 6.2 Windows Server 2012= 6.2 Windows 7= 6.1 Windows Server 2008 R2= 6.1 Windows Server 2008= 6.0 Windows Vista= 6.0 Windows Server 2003 R2= 5.2 Windows Server 2003= 5.2 Windows XP 64-Bit Ed= 5.2 Windows XP= 5.1 Windows 2000= 5.0 Source: https://docs.microsoft.com/en-us/windows/desktop/SysInfo/operating-system-version |
||||||||
|
|
|||||||
Thank you Alex. Just so everyone knows, @dos indeed returns 10.0 on windows 10 but after some updates it can also return 6.1 this seems to have to do with windows 10 not guarding the value in: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion where kix seems to get it. I have only seen this issue once and I believe it was after a .net installation/patch. |