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.

 


 

Start using Login VSI today

Our industry-standard software is built to help you avoid problems, lower costs and improve performance. Request a Quote or get your free Trial below, and benefit from our award-winning services.

Free Price Request  Your Free Trial

 


About the company Login VSI

The company Login VSI provides end-user performance insights for virtualized desktop and server-based computing environments. Enterprise IT departments use flagship product Login VSI (for load testing) and Login PI (for continuity testing) in all phases of their virtual desktop deployment—from planning to deployment to change management—to build and safeguard a good performance, a high availability, and (as a result) a good and consistent end-user experience. For more information about Login VSI or for a free test license contact us.

Tags: How-to, Microsoft

Popular Blogs

Login VSI Blog - Ongoing Effects CPU Flaws

The Ongoing Effects of Intel CPU Flaws

The Ongoing Effects of Intel CPU Flaws Over the last year, we’ve seen many Intel CPU hardware flaws come to light and when news first broke about Meltdown & Spectre there was a lot of panic: "should we patch?", "What’s the performance impact?", "Can we still rely on this hardware?" 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 - 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
A Practical Guide To VDI Change Management, Part 3

A Practical Guide to VDI Change Management

Part 3: Change Accelerates with Windows 10 The third in an 8-part series, this practical guide to VDI Change Management gives you the low-down on the what, why and how of Windows 10 updates and changes Continue Reading
Login VSI Blog - Teaser Image - A Practical Guide to VDI Change Management - Part 2

A Practical Guide to VDI Change Management

Part 2: Why VDI is very sensitive to change The second in an 8-part series, this practical guide to VDI Change Management highlights the importance of effective Change Management. With all the complexities of VDI environments, any failure can severely impact your business. Continue Reading
Login AT Express offers Application Compatibility Testing for up to 50 applications for FREE

[Press Release] Login VSI introduces free license for award winning solution, Login AT

Login AT Express offers Application Compatibility Testing for up to 50 applications for FREE Atlanta, USA, May 22, 2019: Login VSI, the industry standard for VDI and SBC performance testing, announced today the availability of a new, free version of Login AT for Bulk Application Compatibility Testing. Continue Reading
Cookie Settings