Archive: WMI query/logic not working


WMI query/logic not working
  I am using the WMI header:
http://nsis.sourceforge.net/WMI_header

${WMIGetInfo} rootCIMV2 Win32_SystemEnclosure ChassisTypes fnc_Laptop_Test 

>

  Function fnc_Laptop_Test

${If} $INSTALL_VPN != ""
goto _func-end
${EndIf}

!
insertmacro logme ${INSTLOG} "- Processing detected chassis type: $R2" l

${If} $R2 == "{1}"
!insertmacro logme ${INSTLOG} "- Chassis Type: Other" l
${ElseIf} $R2 == "{2}"
!insertmacro logme ${INSTLOG} "- Chassis Type: Unknown" l
${ElseIf} $R2 == "{3}"
StrCpy $INSTALL_VPN 0
!insertmacro logme ${INSTLOG} "- Chassis Type: Desktop" l
!insertmacro logme ${INSTLOG} "- Desktop Detected" l
${ElseIf} $R2 == "{4}"
StrCpy $INSTALL_VPN 0
!insertmacro logme ${INSTLOG} "- Chassis Type: Low Profile Desktop" l
!insertmacro logme ${INSTLOG} "- Desktop Detected" l
${ElseIf} $R2 == "{5}"
StrCpy $INSTALL_VPN 0
!insertmacro logme ${INSTLOG} "- Chassis Type: Pizza Box" l
!insertmacro logme ${INSTLOG} "- Desktop Detected" l
${ElseIf} $R2 == "{6}"
StrCpy $INSTALL_VPN 0
!insertmacro logme ${INSTLOG} "- Chassis Type: Mini Tower" l
!insertmacro logme ${INSTLOG} "- Desktop Detected" l
${ElseIf} $R2 == "{7}"
StrCpy $INSTALL_VPN 0
!insertmacro logme ${INSTLOG} "- Chassis Type: Tower" l
!insertmacro logme ${INSTLOG} "- Desktop Detected" l
${ElseIf} $R2 == "{8}"
StrCpy $INSTALL_VPN 1
!insertmacro logme ${INSTLOG} "- Chassis Type: Portable" l
!insertmacro logme ${INSTLOG} "- Laptop Detected" l
${ElseIf} $R2 == "{9}"
StrCpy $INSTALL_VPN 1
!insertmacro logme ${INSTLOG} "- Chassis Type: Laptop" l
!insertmacro logme ${INSTLOG} "- Laptop Detected" l
${ElseIf} $R2 == "{10}"
StrCpy $INSTALL_VPN 1
!insertmacro logme ${INSTLOG} "- Chassis Type: Notebook" l
!insertmacro logme ${INSTLOG} "- Laptop Detected" l
${ElseIf} $R2 == "{11}"
!insertmacro logme ${INSTLOG} "- Chassis Type: Hand Held" l
${ElseIf} $R2 == "{12}"
StrCpy $INSTALL_VPN 1
!insertmacro logme ${INSTLOG} "- Chassis Type: Docking Station" l
!insertmacro logme ${INSTLOG} "- Laptop Detected" l
${ElseIf} $R2 == "{13}"
StrCpy $INSTALL_VPN 0
!insertmacro logme ${INSTLOG} "- Chassis Type: All in One" l
!insertmacro logme ${INSTLOG} "- Desktop Detected" l
${ElseIf} $R2 == "{14}"
StrCpy $INSTALL_VPN 1
!insertmacro logme ${INSTLOG} "- Chassis Type: Sub Notebook" l
!insertmacro logme ${INSTLOG} "- Laptop Detected" l
${ElseIf} $R2 == "{15}"
StrCpy $INSTALL_VPN 0
!insertmacro logme ${INSTLOG} "- Chassis Type: Space-Saving" l
!insertmacro logme ${INSTLOG} "- Desktop Detected" l
${ElseIf} $R2 == "{16}"
StrCpy $INSTALL_VPN 0
!insertmacro logme ${INSTLOG} "- Chassis Type: Lunch Box" l
!insertmacro logme ${INSTLOG} "- Desktop Detected" l
${ElseIf} $R2 == "{17}"
!insertmacro logme ${INSTLOG} "- Chassis Type: Main System Chassis" l
${ElseIf} $R2 == "{18}"
StrCpy $INSTALL_VPN 1
!insertmacro logme ${INSTLOG} "- Chassis Type: Expansion Chassis" l
!insertmacro logme ${INSTLOG} "- Laptop Detected" l
${ElseIf} $R2 == "{19}"
!insertmacro logme ${INSTLOG} "- Chassis Type: Sub Chassis" l
${ElseIf} $R2 == "{20}"
!insertmacro logme ${INSTLOG} "- Chassis Type: Bus Expansion Chassis" l
${ElseIf} $R2 == "{21}"
StrCpy $INSTALL_VPN 1
!insertmacro logme ${INSTLOG} "- Chassis Type: Peripheral Chassis" l
!insertmacro logme ${INSTLOG} "- Laptop Detected" l
${ElseIf} $R2 == "{22}"
!insertmacro logme ${INSTLOG} "- Chassis Type: Storage Chassis" l
${ElseIf} $R2 == "{23}"
!insertmacro logme ${INSTLOG} "- Chassis Type: Rack Mount Chassis" l
${ElseIf} $R2 == "{24}"
!insertmacro logme ${INSTLOG} "- Chassis Type: Sealed-Case PC" l
${EndIf}

_func-end:
FunctionEnd
>
I get in my log file for ex., Processing detected chassis type: {1}

Which means $R2 == "{1}"

But it is not processing the logic for that variable... I am not sure if it is returning some type of ascii that is not making it truly = to {1}. I do see in the WMI.nsh file they are stripping CRLF's...


1 

>
This is the next like, I am not sure 110% what it is doing, but almost looks like it is adding back in a new line..


"$\n" "$1" 

Any Help would be appreciated...

Thanks,

Squirre1

Put it in a MessageBox surrounded by some extra characters to be sure there are no new lines in the string.

Stu


Good call afrow, I was trying to do a char to ascii earlier after trimming the { } off of it... my output looks like it has a tab in it...

"R2 = before$R2after" 


R2 = before{1}        after 

>
Looks like I have a trim out a tab somehow.. Ill take ideas but should have a solution when you next read this...

Thanks,

Squirre1

Since I am only worried about parsing the digits out, I just did this filter and it dumped everything else...


    ${StrFilter} $R2 "1" "" "" $R2 

>
Thanks again,

Squirre1