$theTitle=wp_title(" - ", false); if($theTitle != "") { ?>
About Virtualization, VDI, SBC, Application Compatibility and anything else I feel like
28 Dec // php the_time('Y') ?>
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
8 Responses for "Using the CorrectFilePaths shim to redirect an ini file to a writable location"
[…] today I wrote about Using the CorrectFilePaths shim to redirect an ini file to a writable location and believe it or not the next application I was working with today needed a nice shim as […]
[…] Dit blogartikel was vermeld op Twitter door Helge Klein. Helge Klein heeft gezegd: RT @RemkoWeijnen: Blogged: Using the CorrectFilePaths shim to redirect an ini file to a writable location http://bit.ly/fANCVj < Good info! […]
[…] you are not familiar with the Application Compability Toolkit please read my earlier post Using the CorrectFilePaths shim to redirect an ini file to a writable location and Using the CorrectFilePaths Shim with Visual Basic […]
[…] Using the CorrectFilePaths shim to redirect an ini file to a writable location […]
Unfortunately, this doesn’t work for 64bit apps, because the CorrectFilePaths were invented for 32bit apps from win9x migrated to XP.
So this shim is not available in the 64bit Compatibility Administrator.
[…] the Appcompat-guy) that the folder we are redirecting to needs to exist. Remko Weijnen did quite a few write-ups which explains several scenarios that this can be used for. Even vendors recommends using shims! […]
You can always use api hooking to get the job done. More invasive than having an OS shim, but its better than nothing.
Have a look at winapioverride
[…] let’s create the redirect shim (if you are new to Application Compatibility read this article […]
Leave a reply