7 Replies Latest reply on Dec 11, 2019 11:41 AM by DEMdev

    Condition based on REG_SZ_MULTI value

    GuntherLmn Lurker

      Hi,

       

      Is it possible to use the presence of any value within a registry REG_SZ_MULTI string as a condition ?

       

      I've tried to use "contains" and "regex" but none of them are working. They result in an unsupported type 7 error in the log.

       

      Kind regards,

      Gunther

        • 1. Re: Condition based on REG_SZ_MULTI value
          DEMdev Master
          VMware Employees

          Hi Gunther,

           

          No, I'm afraid not. I just checked the code, and only registry values of type REG_SZ, REG_EXPAND_SZ, and REG_DWORD are supported – anything else will result in that "unsupported value type" log message.

          • 2. Re: Condition based on REG_SZ_MULTI value
            GuntherLmn Lurker

            Hi DEMdev,

             

            Is there a technical limitation why this is not supported ? I am trying to read the current UI language from the registry to provide language based shortcuts.

            I guess I can script around this limitation or maybe someone has done this before ?

             

            kind regards,

             

            Gunther

            • 3. Re: Condition based on REG_SZ_MULTI value
              DEMdev Master
              VMware Employees

              Hi Gunther,

              Is there a technical limitation why this is not supported ?

              Not really; it's just that REG_SZ_MULTI does not map nicely to the comparison operators "Is equal to" or "Matches regex" if the value contains multiple strings. Similarly in that situation, logging its data would need some special treatment.

              Neither of those things is difficult to address, of course, but we always need to balance development effort and expected value.

               

              As for "maybe someone has done this before", I can actually reuse something I looked into for an answer that I gave in a completely different thread earlier today ...

               

              You can create a logon task as follows (make sure to mark it to run Before profile archive import):

              For easier copy/pasting: CMD.EXE /C FOR /F "tokens=2*" %A IN ('REG QUERY "HKCU\Control Panel\Desktop" /v PreferredUILanguages') DO SETX PrefLang %B

               

              You can then reference that PrefLang env var in an environment variable condition:

              2019-11-19 17:45:13.044 [DEBUG] Conditions: Check for environment variable 'PrefLang' = true ('nl-NL\0en-US' contains 'en-us')

              2019-11-19 17:45:13.094 [INFO ] Successfully created shortcut on desktop ('test.xml')

               

              Please note that reg.exe outputs "\0" to separate multiple string entries (in reference to my "logging its data would need some special treatment" statement above .)

              1 person found this helpful
              • 4. Re: Condition based on REG_SZ_MULTI value
                GuntherLmn Lurker

                Hi DEMdev,

                 

                Thanks for this quick response. This is not working on non-persistent desktops. If you change the UI language in Windows there is a second key generated PreferredUILanguagesPending.

                Somewhere in the logon process this key is transferred to the PreferredUILanguages and applied to the UI. For this to be captured I also use the Multilanguage UI Settings config file.

                 

                So If the PrefLang variable is created before the archive import, I keep getting the default language UI and not the one I changed to.

                 

                I can play with some timers but I'll probably pass by the shortcut creation process, resulting in the shortcut not being created.

                 

                any extra thoughts ?

                • 5. Re: Condition based on REG_SZ_MULTI value
                  DEMdev Master
                  VMware Employees

                  Hi Gunther,

                   

                  I understand. Maybe the easiest way to do this (without depending on timer hacks) would be to perform a shortcut refresh once File Explorer has started, and also postpone setting that environment variable until that time.

                   

                  So, rather than creating that logon task, you could create a batch file with something like the following content (note the change from using SETX to SET):

                   

                  FOR /F "tokens=2*" %A IN ('REG QUERY "HKCU\Control Panel\Desktop" /v PreferredUILanguages') DO SET PrefLang=%B

                  "C:\Program Files\Immidio\Flex Profiles\FlexEngine.exe" -UEMRefreshShortcuts

                   

                  You can then use File Explorer's Run key to have Explorer launch your batch file shortly after it starts.

                   

                  If you have many shortcuts defined in UEM and want to prevent having them always be processed twice (once at logon, only to have them immediately refreshed afterwards), you can disable shortcut processing at logon. The advanced ADMX template allows you to configure the Disable UEM action types policy setting, which has a Disable UEM Shortcuts during logon option (if you're using NoAD, the equivalent XML setting would be UEMActionShortCutDuringLogon="0".) With that configuration, the UEM agent won't process any shortcuts at logon.

                  1 person found this helpful
                  • 6. Re: Condition based on REG_SZ_MULTI value
                    GuntherLmn Lurker

                    Hi DEMdev,

                     

                    Thanks again for this solution, it works ! (after adding double% instead of single because it is used within a cmd)

                    Only remark is that it executes pretty late when the user has already opened the start menu and has to wait for the icons to refresh or clearly sees another refresh when refreshing twice.

                     

                    Feature request: DEM native functionality/variable to reflect the current UI language ? :-)

                     

                    greetings,

                    Gunther

                    • 7. Re: Condition based on REG_SZ_MULTI value
                      DEMdev Master
                      VMware Employees

                      Hi Gunther,

                       

                      Happy to hear it's working! And sorry about those single % signs – it did cross my mind after posting it, and I then even went to check whether I did it correctly in that other forum post I referenced, but forgot to fix it in this thread...

                       

                      As for the "executing pretty late": are you aware of REG_DWORD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Serialize@StartupDelayInMSec? By default, Windows 10 (and possibly earlier) waits a while (10 seconds?) once File Explorer has started before processing Run entries. If you set StartupDelayInMSec to 0, it happens a bit sooner.

                       

                      I'll add your feature request to my todo list. No guarantees, but I'll take a look some time

                      1 person found this helpful