CorrectFilePaths Has to Point to a Directory Which Exists

A question came up via comments. (I was going to say that it came up recently, but another glance reveals that it came up in, oh, June. I don’t think I can fairly call that recent…)

“…the fix seems only to work if the directory structure exists…”

This is true, and worth noting. If you point the fix to a directory which doesn’t exist, the shim won’t create the directory, it will just fail, in much the same way the application would fail if it were trying to create an application in a directory which didn’t exist (which, to Windows, appears to be exactly what happened). So, if you’re planning to shim an application and want to create a directory to store things, you should consider creating this directory at install time.

Comments (14)

  1. ABC says:

    Hi Chrish,

    I have 3 files, which I have to redirect to per user location.

    But When I am trying to create SDB file using CA. Here I am able to select only one Correct File path shim.

    If I want to redirect other 2 files then do I need to create 2 more SDB files or shall I put all these 3 paths into the same SDB?…


  2. ABC says:

    Howmany characters I can enter into the Parameter filed, when I am using the Correct File path shim.

    I tried it was taking only upto 100-120 characters. If I have a path which exceeds this limit, is there any other way to apply this shim?


  3. cjacks says:

    Oh, and for the earlier question – just space delimit multiple paths in the command line. You don’t apply the shim multiple times.

  4. ABC says:

    Thanks Chris,

    for the commandline limit, I have seen it can support upto 1024, But when I was working it is not accepting more than 104 characters…..

    If it is 1024, it is really gud. But how to proceed if it is the case with 104

  5. cjacks says:

    1024 is the limit for the shim command line. if you’re talking about 0x104 (though speaking in hex would be a big unexpected), then that’s MAX_PATH, which is a limit for each path in the arguments you’re providing.

  6. ABC says:


    sorry chrish, I did not get you the limit wht u r talking abt?……..

    when we r creating the correct file path shim, there is a parameter button, which we genrally use to provide the path. But here it is accepting only upto 104 characters……but I have a path, which needs to be redirected to virtual folder, which is having a length of 300characters, then how can I proceed here?

    and u r telling we can add mutiple paths in single shim with delimit char. Really tht’s fine…

  7. cjacks says:

    Each path is limited to being MAX_PATH characters long (0x104 = 160 characters). You can string pairs of paths together up to the maximum command line length – 1,024 characters. If a single path is 300 characters long, then you’ll have to find some way to shorten it.

  8. ABC says:

    Hi Chirs,

    I tried my level best to shorten the path(tried with environmental var), but still it is exceeding the 160 characters. So in this case how can I apply the Correct File Path shim?.

    Is there any other shims to redirect the files/registries?

    what are the environment variables can we use for this correct file path?

    please guide me how to apply shims in this senario(redirecting the files/regirstries)

  9. cjacks says:

    Try using short file names.

  10. Aaron Margosis says:

    Short paths will work only if the calling program uses short paths, correct?

    The "at install time" that you refer to in the last line of the post needs to be the "per user" install time — the installing user and the actual app user are generally not going to be the same.  Perhaps you need to run a simple batch file to create the folders before you run the app for the first time?

    Is the same true for VirtualRegistry as well?

  11. cjacks says:

    We convert paths to short names internally when we set up the data structures for doing the conversions, so in most cases the short path should work identically.

    Yes, if you need to set up per-user redirection locations, then you’ll need to do so in the user’s context.

  12. Stefan Kanthak says:

    But short names don’t necessarily exist on NTFS (see MSKB 121007 and 210638)!

    JFTR: I setup all of my NT systems since NT4 with "NTFSDisable8dot3NameCreation" in the SETUPREG.HIV (and create sentinels, i.e. empty .EXE files, like "C:Program.exe" where appropriate/necessary) just to catch all those poor written apps which stumble over blanks in pathnames.

    Since about 4 years those poor apps have almost vanished here… except for Windows XP and .REG.-)

Skip to main content