login vsi company logo login vsi company logo 250x40

 

Get the best possible VDI performance, density and availability with Login VSI
Our Solutions

  • Home
  • Blog
  • Solve Multi User Issues In Environments without App-V by Using Expandable Strings

Solve Multi User Issues In Environments without App-V by Using Expandable Strings

Solve Multi User Issues In Environments without App-V by Using Expandable Strings

I’m describing a situation that is typically solved by application virtualization using Microsoft App-V or any other application virtualization product but I still encounter a lot of companies that do not want to virtualize their apps. In my mind, with good reason. This post is about a simple trick using the Windows registry that may help you to personalize an application that stores its settings in HKEY_LOCAL_MACHINE. The trick is about strings and expandable strings.

Imagine an application called BadApp. Now, imagine that when the BadApp is installed, the installer of BadApp stores some settings about BadApp in HKLM. One of these settings could for instance be where BadApp stores its cache (or whatever). In the registry a value with the following settings may have been added:

registry editor badapp

Registry Editor BadApp

Now when a different user logs on to the system and tries to use BadApp, the application doesn’t work properly. Very annoying indeed. On a traditional desktop the solution to this issue may not prove too difficult to solve; simply change the value to c:\BadAppCache right? But on a terminal server this may not be the right answer because you would end up with multiple users using the same cache folder (as BadApp is an imaginary app and I have no idea what is does and why this cache is needed, my gut feeling tells me that I should share this cache with multiple users).

If I use my primary interface to windows and retrieve the value of CacheLocation, I would see this very unsurprising result:

windows powershell value of cachelocation

Windows PowerShell value of CacheLocation

I really want this value to point to my profile, instead of the administrator’s profile. So let’s try to change the registry value like this:

registry editor

Registry Editor

So let’s look at the output of my PowerShell command again:

windows powershell command

Windows PowerShell command

Again, not very surprising. Depending on how the application was written, this may have solved the problem. Only way to find out is to start BadApp and see what happens. Unfortunately, I did a mental launch of BadApp and I must info that BadApp failed to launch with the error message:

BadApp failed: could not find the path “%userprofile%\BadApp\Cache”.

So, now let’s try something different. Let’s change the type of the registry value from a string (REG_SZ) to an expandable string (REG_EXPAND_SZ) and see what happens (apart from the wider screenshot):

expandable string

Registry Editor - expandable string

And the output:

windows powershell output

Windows PowerShell output

As you can see, the value is first expanded and then displayed. Below, you will find some C code that uses the Win32 API to read the content of a string value from the registry. This code does not enforce the registry value to be a REG_SZ and will behave in the same way as the PowerShell example I’ve shown earlier.

#include"stdafx.h"
#include<windows.h>
#include<stdio.h>
int_tmain(int argc, _TCHAR* argv[])
{
      LONG returnStatus;
      DWORD Size=0; 
      returnStatus = RegGetValueA(HKEY_LOCAL_MACHINE, (LPCSTR) 
"SOFTWARE\\ BadApp", (LPCSTR) "CacheLocation",RRF_RT_ANY,NULL, NULL, (LPDWORD) &Size);         
      char * buffer = (char *) malloc(Size);         
      returnStatus = RegGetValueA(HKEY_LOCAL_MACHINE, (LPCSTR) 
"SOFTWARE\\ BadApp", (LPCSTR) "CacheLocation",RRF_RT_ANY,NULL, (LPBYTE)buffer, (LPDWORD) &Size);         
      printf("Value from registry %s\n",buffer);         
      delete [] buffer;         
      system("pause"); 
}          

The code above produces the following output:

badapp output

Code output

So does this work for all applications? I’m afraid not, it depends on how the application was written. But see it as yet another tool in your toolkit that may allow for a simple solution to a simple problem.

By the way, if you need to convert a string value to an expandable string in a .reg file you might find the PowerShell code below to suite your needs:

"%userprofile%\BadApp\Cache" | %{"hex(2):" + [string]::join(",",( ([char[]] $_) | %{ "{0:X4}" -f [int16] $_ } | %{"$($_[2])$($_[3]),$($_[0])$($_[1])"})) +",00,00"}

Hope this trick also works for you.

Tags: How-to, Microsoft

Popular Blogs

Login VSI - Press Release - IGEL - Login VSI Partner to Optimize End User Computing Experience Image

[Press Release] IGEL Partners with Login VSI to Optimize the End User Computing Experience

Login PI enables organizations to better protect the performance and availability of their IGEL OS-powered virtual desktop environments Continue Reading
Login VSI - Blog - Login PI Blog Teaser Image - Windows Virtual Desktop: How To Monitor User Experience With Login PI

Windows Virtual Desktop – How to Monitor User Experience?

Microsoft has just announced the public preview of their new Windows Virtual Desktop (WVD) offering at Microsoft Ignite on Tour in Amsterdam today. For those of you who’ve not followed the rumors or the private beta, here’s the outline... Continue Reading
Login VSI Blog - Teaser Image - A Practical Guide to VDI Change Management - Part 1

A Practical Guide to VDI Change Management

Part 1: IT Change Management in general The first in an 8-part series, this practical guide to VDI Change Management will guide you through the transformation of the IT department from a back-end function into a core competency for every modern organization. Continue Reading
Investigating Online Application Performance with Login PI

Investigating Online Application Performance with Login PI

As many companies do, we use a CRM system. Recently, I have been getting complaints about our cloud CRM system, Microsoft Dynamics, being slow. I tried to investigate this by shadowing one of our users to see what was wrong. Continue Reading
Login VSI Blog - How-To Update, Protect Against RIDL, Fallout MDS Vulnerability

How-To: Update, Protect Against RIDL, Fallout MDS Vulnerability

RIDL & Fallout MDS vulnerabilities, impact on VDI performance & actions to take. FAQs we’re receiving & updates on performance tests executed to patch flaws Intel calls “Microarchitectural Data Sampling (M.D.S.)” aka: Rogue In-Flight Data Load (RIDL), Fallout, ZombieLoad & Store-to-Leak Forwarding. Continue Reading
Login VSI -Blog Post - IGEL Partner with Login VSI

Login PI & IGEL: Delivering Deep Application Test & Availability Monitoring

Together Login VSI and IGEL deliver deep application test and availability monitoring for the digital workspace This week we announced a partnership with IGEL that enables Login PI integration in a radical new way. Continue Reading
Cookie Settings