Touch the exe, after you added a manifest for it, in Vista


You are an enthusiastic and responsible developer. You love programming, and you love programming the right way.

So you get the latest and greatest Windows Vista. You try your hard-worked amazing.exe application in Vista. Did not work. Apparently, amazing.exe needs admin privilege to do wonderful things. But in Vista, the user by default does not have admin privilege.

You did your research. You understand that you need to add a manifest to your application, and declare that the application requires administrator in the manifest. So you added amazing.exe.manifest, and put it next to amazing.exe.

Did not work. Amazing.exe did not get admin privilege.

You double checked the syntax of the manifest. Yes, it is right. You compared it to another working example. Yes, they are the same. You run amazing.exe again. Still did not work.

You are angry. What is going on, Microsoft?

The truth is, in Windows Vista, in order to improve CreateProcess performance, we cache the fact that an exe has manifest or not. The key to this cache, are the full path of the exe, and the last modified time of the exe file.

After you execute the exe without manifest, when you add a manifest to the exe, in order for the OS to see the manifest, you need to change the last modified time of the exe (or simply say, touch the exe), to invalidate the cache entry for the exe.

The cache only exists in memory, and is never flushed to disk. On reboot the cache starts clean.

At the time we did the work, our measurement shows that the cache improved CreateProcess performance by 10-15% in warm case, when the application does not have manifest.

So remember, touch the exe, after you added a manifest for it, in Vista.

Comments (6)

  1. CoqBlog says:

    Petite information intéressante, lue sur le blog de Junfeng Zhang , à garder à l’esprit lorsque vous

  2. wva says:

    Caching is a neat technique. But why you should speed up CreateProcess? A process will normally live thousands/millions times longer then the duration of single CreateProcess(). So at the end, you seem to gain nothing with this trick. Really, I’d like to see a scenario where this optimization helps much.

  3. Noel Adorno says:

    Instead of running "touch" to change the date on the amazing.exe, why not just add the manifest to amazing.exe using the command line tool mt.exe that ships with the SDK?  The command line help is a bit cryptic, but it does do the job.  Then you only need to run one tool and you can ship one less file with your amazing.exe.

  4. I found that even a full restart did not clear the cache. The Manifest was only detected if I used ‘Touch’, or renamed the file & manifest to a new filename.

    Is there a method to clear the cached entry?

    – Ryan Pertusio

  5. Full restart should clear the cache. If it does not work for you, maybe your application is run during the boot.

  6. happyjet says:

    I found that even a full restart did not clear the cache, too.

    I want to know whether there are any method to clear the cached entry, too.

Skip to main content