Using CorrectFilePaths Shim to Fix Broken Applications

In this article, we will look at how to create a File redirection and make the application point to a new File Path instead of the old one!

The Compatibility Administrator tool enables you to resolve many of your potential application-compatibility issues before deploying a new version of Windows in your organization. This tool enables you to create customized compatibility fixes, compatibility modes, AppHelp messages, and compatibility databases. To know more on how to create one and implement it, Read – Creating a Shim/Fix Using Compatibility Administrator.

Scenario: When I launch this application, and press on the update button, i get this below error dialog which says “Access to a certain path is denied”. This can occur in a locked down environment or as a part of the User Account Control, where the user works as a Standard User unless he elevates explicitly.

File Access Error

This application stores the configuration preferences in an ini file which gets saved in the folder C:\Windows\Downloaded Program Files\. This is a protected folder and a Standard User will not have permissions to write on it. We will need to change the path to a folder where a normal user will have the access, the %APPDATA% (User Profile’s Application Data) folder.

In this post,we will change this file path; make this application to point to the new folder, so that when this file tries to get saved…we do not get an access denied error. CorrectFilePaths Shim exactly helps us in doing so!

Step 1: Launch the Application Compatibility Administrator, and create a new Application Shim. Select CorrectFilePaths Shim and press the parameters button. This will give you options to configure the paths. You will need to use the ADDREDIRECT command.

CorrectFilePaths Shim

Step 2: Give the parameters for this shim.

General Syntax: “oldpath”;”newpath” . In this case, we will give it as  “C:\Windows\Downloaded Program Files\StockViewer.ini”;”%USERAPPDATA%\StockViewer.ini”

Parameters - Correct File Path Shim

Step 3: Apply the shim and test the application.

Now, when I click on the Save Preferences button, the configuration File gets saved. What happens in background is that, the hard-coded path is redirected to the new one. The User Application Data folder has the write access and hence the file gets created!

Redirected File gets Created in the User AppData

This mitigation technique can be used for any file path redirection. If you have any application which is hard-coded and writes to a particular restricted file paths, this technique can make it refer a new path and hence give you access.

If you have issues with Hard-coded registry key paths, then do read this article!


Leave a Reply

Your email address will not be published. Required fields are marked *