Today I needed to package an application called PlesirReality and I noticed that it wrote an ini file into the program directory (in my case D:\Apps\PlesirReality).

I looked into this ini file (areastate.ini) and it writes user settings in there, like the last position of the window etc.

We can see this easily with Process Monitor:


This presents us with several problems:

The first problem is that the user does not have write permission in this directory so upon application exit we get an ugly error message:


We could “fix” this by giving the user write permissions to this directory or even to this specific file but here comes the seconds problem:

On a multi user environment like Citrix or Terminal Server/Remote Desktop Services it means that when one user exists he will he save his settings for all users.

And then we have a third problem:

When a users starts the application on another server he will not get the expected settings because each server will have it’s own copy of this ini file.

Luckily Microsoft has a solution for us and it’s called the Application Compatiblity Toolkit. I learned about it on the Teched Emea in 2008 in an excellent session from Chris Jackson.

So let’s fix it!

On a test environment start the Compatibility Administrator (32-bit):


Create a new Database and save it (I named it PleasirRealtiy) and then click the Fix button. Use the Browse to point the to the executable and give it a meaningfull name:


Click Next in the following Screen:


Now select the CorrectFilePaths shim and click Parameters:


The Command line should be “Original filename;New filename”, in my case I am redirecting the file to the user’s homedirectory (H:) in the Windows subdir:


Now Click OK, followed by Next. In the Matching Information screen you can limit the Fix to properties such as the version of the executable. This is usefull to prevent that you will apply the fix to future versions. But for now we will not use this so just click Finish:


Now you need to save the Database and Install it:


And we can use Process Monitor to verify the results:


As you can see the Application tries to open D:\Apps\PlesirReality but is redirector to H:\Windows\areastate.ini.

There is one final step: we need to install the database on all of our systems, this can be done using the sdbinst.exe tool that comes with windows (%systemroot%\system32\sdbinst.exe).

SdbInst /? shows the cmdline switches:


So we can install using sdbinst <databasename>:


Or quietly using -q: sdbinst -q PlesirReality.sdb

If you would like to learn more about using Shims to fix applications then see: TechNet Virtual Lab: Mitigating Application Issues Using Shims