次の方法で共有


Using the CorrectFilePaths Fix

Applies To: Windows 7, Windows Vista

This section includes information about using the CorrectFilePaths compatibility fix, including the available variables, command-line options, usage, and any default file path and API-related information.

CorrectFilePaths

CorrectFilePaths enables you to modify an existing file path, so that it redirects to a new file path location. This compatibility fix contains several default corrections, in addition to enabling you to add custom corrections.

Important

These corrections are not environmental variables. Both the old and new file path locations are searched for this variable.

This compatibility fix might perform up to three complete passes to correct all of your file path location redirections.

Investigating the Issue

Application-related issues that can be resolved by applying the CorrectFilePaths compatibility fix are typically detected by a User Account Control (UAC) detection tool, such as Standard User Analyzer (SUA), or by a file monitoring tool, such as Process Monitor. In either of these tools, you will look for files to which you have been denied access or where an application has been unable to locate an expected file.

Intercepted APIs

The following sections provide a list of APIs that are intercepted by the CorrectFilePaths compatibility fix. The APIs are grouped according to the configurable section.

CreateProcess Routines

The following routines are classified within the CreateProcess configuration group.

  • CreateProcessA / CreateProcessW

  • WinExec

  • ShellExecuteA / ShellExecuteW

  • ShellExecuteExA / ShellExecuteExW

GetCommandLine Routines

The following routines are classified within the GetCommandLine configuration group.

Note

The routines included in this category are disabled by default.

  • GetCommandLineA / GetCommandLineW

Profile Routines

The following routines are classified within the Profile configuration group.

  • GetPrivateProfileIntA / GetPrivateProfileIntW

  • GetPrivateProfileSectionA / GetPrivateProfileSectionW

  • GetPrivateProfileSectionNamesA / GetPrivateProfileSectionNamesW

  • GetPrivateProfileStringA / GetPrivateProfileStringW

  • GetPrivateProfileStructA / GetPrivateProfileStructW

  • WritePrivateProfileSectionA / WritePrivateProfileSectionW

  • WritePrivateProfileStringA / WritePrivateProfileStringW

  • WritePrivateProfileStructA / WritePrivateProfileStructW

File Routines

The following routines are classified within the File configuration group.

  • CopyFileA / CopyFileW

  • CopyFileExA / CopyFileExW

  • CreateDirectoryA / CreateDirectoryW

  • CreateDirectoryExA / CreateDirectoryExW

  • CreateFileA / CreateFileW

  • DeleteFileA /DeleteFileW

  • FindFirstFileA / FindFirstFileW

  • FindFirstFileExA / FindFirstFileExW

  • GetBinaryTypeA / GetBinaryTypeW

  • GetFileAttributesA / GetFileAttributesW

  • GetFileAttributesExA / GetFileAttributesExW

  • SetFileAttributesA / SetFileAttributesW

  • GetTempFileNameA / GetTempFileNameW

  • GetLongPathNameA / GetLongPathNameW

  • MoveFileA / MoveFileW

  • MoveFileExA / MoveFileExW

  • MoveFileWithProgressA / MoveFileWithProgressW

  • RemoveDirectoryA / RemoveDirectoryW

  • SetCurrentDirectoryA / SetCurrentDirectoryW

  • OpenFile

  • _lopen

  • _lcreat

Registry Set Value Routines

The following routines are classified within the Registry Set Value configuration group.

Note

The routines included in this category are disabled by default.

  • RegSetValueA / RegSetValueW

  • RegSetValueExA / RegSetValueExW

The following routines are classified within the ShellLink configuration group.

  • IShellLinkA::SetPath / IShellLinkW::SetPath

  • IShellLinkA::SetArguments / IShellLinkW::SetArguments

  • IShellLinkA::SetIconLocation / IShellLinkW::SetIconLocation

  • IPersistFile::Save

LoadImage Routines

The following routines are classified within the LoadImage configuration group.

  • LoadImageA

CorrectFilePaths Command-Line Options

The following table provides the command-line options that can be used to modify the behavior of the CorrectFilePaths compatibility fix.

Important

The command-line options that contain a minus (-) symbol subtract from the default functionality of the fix, while the command-line options with a (+) symbol adds to the default functionality. All command-line options must be entered at the beginning of the command-line syntax.

Command-Line Option Description

-a

Provides the default corrections, including the All Users configuration options.

-c

Does not apply fixes to the CreateProcess routines.

-f

Does not apply fixes to the File routines.

-p

Does not apply fixes to the Profile routines.

-s

Does not apply fixes to the ShellLink routines.

-b

Does not apply any of the default corrections.

-u

Provides the default corrections, including the User configuration options.

+GetCommandLine

Applies fixes to the GetCommandLine routines.

+RegSetValue

Applies fixes to the Registry Set Value routines.

+LoadBitmap

Applies fixes to the LoadImage routines.

+Win9xPath

Applies the default Windows 9x path-specific fixes.

-Profiles

Provides the default corrections, including the User configuration options. This is the same as using the -u option.

old_file_path;new_file_path "old file path 2;new file path 2"

Replaces instances of the old file path location with the new file path location.

Old file path

The original file path location, which is to be replaced.

New file path

The corrected file path location.

Include additional path corrections separated by spaces.

Important
If the file path name contains spaces, you must enclose the entire pair ("old file path;new file path") in quotes.

Usage Examples

The following section provides examples for how to use the command-line options with the CorrectFilePaths fix.

Example 1: Additional Path Correction

In this example, you will apply the default path corrections, and then you will replace all occurrences of setup.exe with setupapp.exe.

setup.exe;setupapp.exe
Example 2: Additional Path Correction with Spaces

In this example, you will replace mplayer with a full path location to the mplayer2. Pay particular attention to the use of straight quotation marks.

"mplayer;%PROGRAMFILES%\Windows Media Player\mplayer2"
Example 3: Removing All Default Path Corrections

In this example, you will replace setup.exe with setupapp.exe, without applying the default path corrections.

-b setup.exe;setupapp.exe
Example 4: Correct Only the CreateProcess Routines

In this example, you will replace setup.exe with setupapp.exe for any CreateProcess routines. You will not apply the default path corrections.

-f -p -s -b setup.exe;setupapp.exe
Example 5: Cumulative Path Corrections

In this example, you will apply the default path corrections, which are still incorrect and must again be modified.

wordpad.exe;%SYSTEMDIR%\wordpad.exe .\%SYSTEMDIR%;%SYSTEMDIR%
Example 6: Creating a Command-Line Syntax Using Quotes

In this exercise, we are going to use the Win9xPath fixes to change all of the paths from C:\Program Files\abc to D:\Program Files\Applications\def.

+Win9xPath "c:\Program Files\abc;d:\Program Files\Applications\def"

Included Modules

The following modules are included by the CorrectFilePaths compatibility fix.

  • shell32.dll

  • ole32.dll

  • shlwapi.dll

Fixing Your Code

File path location issues typically occur when an application attempts to write to a protected area of the file system, or when an application includes a hard-coded file path location that has moved in a newer version of the Windows operating system.

To correct these issues, you must:

  • Modify your application, so that it writes to per-user areas at runtime, or to areas that have been specifically set up for per-computer sharing during the installation process.

  • Modify your application, so that it does not include hard-coded file path locations. Instead, you should use one of the intercepted API calls listed in the Intercepted APIs section of this topic, to resolve the local file path for a particular type of variable.

CorrectFilePaths Default Corrections

Initial Pass (Optional)

The first pass is used to apply the following default corrections to any computer running a version of the Windows 9x operating system.

Important

This pass only occurs if you have configured by using the command-line options listed in the "CorrectFilePaths Command-Line Options" section of this topic. If you do not specify that this pass should occur, it will not run.

  • Converts all "/" characters to "\" characters

  • Removes any blank directory names, for example "abc\ \def" changes to "abc\def"

  • Removes any instances of ".\" from the file path

Second Pass

After the initial pass is complete, the compatibility fix will correct the file path locations, based on your configured requirements. There are several corrections that are available for configuration, based on the following three types of configuration options:

  • Base: Does not apply the default corrections. No file path locations are changed.

  • User: Applies the default corrections by using the per-user settings

  • All Users: Applies the default corrections by using the all-users settings

User Configuration Options

The following table lists all of the default corrections that are included with the User configuration option, listed in the order by which they are applied.

Original File Path Corrected File Path
C:\windows  %WINDIR% 
 %WINDIR% \rundll32.exe  %SYSTEMDIR% \rundll32.exe
 %WINDIR% \rundll.exe  %SYSTEMDIR% \rundll.exe
%WINDIR% \write.exe  %SYSTEMDIR% \write.exe
%WINDIR% \dxdiag.exe  %SYSTEMDIR% \dxdiag.exe
 %WINDIR% \wordpad.exe Returned value from the HKEY_CLASSES_ROOT\Applications\wordpad.exe\shell\open\command registry key. For example, %ProgramFiles% \Windows NT\Accessories\WORDPAD.EXE" "%1
 %PROGRAMFILES% \Accessories\wordpad.exe Returned value from the HKEY_CLASSES_ROOT\Applications\wordpad.exe\shell\open\command registry key. For example, %ProgramFiles% \Windows NT\Accessories\WORDPAD.EXE" "%1
 %WINDIR% \Start Menu  %USERSTARTMENU%  
 %WINDIR% \Desktop  %USERDESKTOP%  
 %WINDIR% \Favorites  %USERFAVORITES% 
 %WINDIR% \%CSIDL_STARTMENU_NAME%  %USERSTARTMENU%  
 %WINDIR% \%CSIDL_DESKTOPDIRECTORY_NAME%  %USERDESKTOP%  
 %WINDIR% \%CSIDL_FAVORITES_NAME%  %USERFAVORITES%  
 %WINDIR% \Profiles\ %USERNAME% \Start Menu  %USERSTARTMENU%  
 %WINDIR% \Profiles\ %USERNAME% \Desktop  %USERDESKTOP% 
 %WINDIR% \Profiles\ %USERNAME% \Favorites  %USERFAVORITES%  
 %WINDIR% \Profiles\ %USERNAME% \%CSIDL_STARTMENU_NAME%  %USERSTARTMENU% 
%WINDIR% \Profiles\ %USERNAME% \%CSIDL_DESKTOPDIRECTORY_NAME% %USERDESKTOP%  
 %WINDIR% \Profiles\ %USERNAME% \%CSIDL_FAVORITES_NAME%  %USERFAVORITES%  
 %WINDIR% \Profiles\All Users\Start Menu  %ALLSTARTMENU%  
 %WINDIR% \Profiles\All Users\Desktop  %ALLDESKTOP% 
 %WINDIR% \Profiles\All Users\Favorites %USERFAVORITES%  
%WINDIR% \Profiles\ %ALLUSERSPROFILE_NAME% \%CSIDL_STARTMENU_NAME%  %ALLSTARTMENU%  
%WINDIR% \Profiles\ %ALLUSERSPROFILE_NAME% \%CSIDL_DESKTOPDIRECTORY_NAME%  %ALLDESKTOP%  
 %WINDIR% \Profiles\ %ALLUSERSPROFILE_NAME% \%CSIDL_FAVORITES_NAME%  %USERFAVORITES%  
DDHELP.EXE DDRAW.DLL
DDRAW16.DLL DDRAW.DLL
DSOUND.VXD DDRAW.DLL
All Users Configuration Options

The All Users configuration option includes the User configuration options listed in the table above, in addition to changing the %USERSTARTMENU% location to the %ALLSTARTMENU% location.

Third Pass (Optional)

During the final pass, the compatibility fix will correct any additional locations that you explicitly included by using the command-line options.

Important

This pass only occurs if you have configured by using the command-line options listed in the "CorrectFilePaths Command-Line Options" section of this topic. If you do not specify that this pass should occur, it will not run.

To correct any additional file path locations during this pass, you must use at least one of the following variables in your command prompt.

  •  %WINDIR%  = returns the value from the GetWindowsDirectoryW function

  •  %SYSTEMROOT%  = returns the value from the GetWindowsDirectoryW function

  •  %SYSTEMDRIVE%  = returns the first two characters from the GetWindowsDirectoryW function

  •  %SYSTEMDIR%  = returns the value from the GetSystemDirectoryW function

  •  %USERNAME%  = returns the value from the GetUserNameW function

  •  %PROGRAMFILES%  = returns the value from the ShGetFolderPathW(…,CSIDL_PROGRAM_FILES, …) function

  •  %USERSTARTMENU%  = returns the value from the ShGetFolderPathW(…,CSIDL_STARTMENU, …) function

  •  %ALLSTARTMENU%  = returns the value from the ShGetFolderPathW(…,CSIDL_COMMON_STARTMENU, …) function

  •  %USERDESKTOP%  = returns the value from the ShGetFolderPathW(…,CSIDL_DESKTOPDIRECTORY, …) function

  •  %ALLDESKTOP%  = returns the value from the ShGetFolderPathW(…,CSIDL_COMMON_DESKTOPDIRECTORY, …) function

  •  %USERFAVORITES%  = returns the value from the ShGetFolderPathW(…,CSIDL_FAVORITES, …) function

  •  %ALLFAVORITES%  = returns the value from the ShGetFolderPathW(…,CSIDL_COMMON_FAVORITES, …) function

  •  %USERAPPDATA%  = returns the value from the ShGetFolderPathW(…,CSIDL_APPDATA, …) function

  •  %ALLAPPDATA%  = returns the value from the ShGetFolderPathW(…,CSIDL_COMMON_APPDATA, …) function

  •  %USERPROFILE%  = returns the value from the GetUserProfileDirectoryW function

  •  %ALLUSERSPROFILE%  = returns the value from the GetAllUsersProfileDirectoryW function

  •  %APPEXEDIR%  = returns the value from the GetModuleFileNameW function

See Also

Concepts

Windows Vista and Windows 7 Operating Systems