Tuesday, July 28, 2009

Advertised Shortcuts: Remember the Mulder!

I ran into a strange issue with an installer the other day. I needed to update two computers so I walked over and copied a new exe into the install directory and walked away. Three days later I noticed that the old program was back on those computers. Were these the same computers? All of the settings changes I made were still there.

A week later, I ran another program and noticed that everytime I performed a task that created any kind of files, the program showed a reinstalling form when trying to run it from the shortcut. I also noticed the shortcut target was not the exe. Hmm, this sounds like something from one of those Microsoft Conferences last year that they were raving about... Something about how Word could be damaged and even uninstalled and would be automatically fixed...

Welcome to Advertised Shortcuts! This behavior is part of the "resiliency" feature of the Windows Installer. When you create a shortcut with your install package they aren't shortcuts to your program. They are shortcuts to the Windows Installer which will check the version installed and if it is modified, will change it back to the proper state. It triggers resiliency.
http://support.microsoft.com/?id=290997
newsgroup info: Clicking on created shortcut trigers...

There are definately some benefits to this feature. For example, it blows away your app if it gets a virus. And, it gives you a warm and fuzzy feeling to know that your software is not going to be abused by someone.

Now for the really bad news. This can be a problem if your program has any external files in the target directory. For example, log files, data files, config files (including changes to the exe.config), temp files, etc. If your program changes anything in there, the next time you click on it, POW! You've just triggered resiliency. Which means your user is watching an installer run and boy I hope it works because if it doesn't they won't be happy. Wait they don't have access rights to install? Oops. Time to panic.

Okay, surely there's a way to just configure the installer package to not use advertised shortcuts? NOPE!! The answer suggested is to use another utility besides Visual Studio to make the installer package such as WIX or InstallShield. Huh? Have you tried WIX? You've just turned your 1 hour install package into an 8 hour march of death. 6 months from now some other programmer will stare in disbelief at that WIX package wondering whether you were chasing the dragon on that day.

There is actually only one flag that needs to change in the install package.
It is: DISABLEADVTSHORTCUTS and it needs to be set to 1.

Now, for the really really bad news. There is no GUI support for this flag! Don't worry, there's a solution.:) What you have to do is download the "Installer SDK" from Microsoft. No, I'm not kidding... You have to install the Installer SDK! You know we all have that. :)

Then, you run ORCA which is a tool to manipulate the data tables for a package and you add this property into the Property tables manually after you build the installer.

If you want to set it up as a Post Build Event in visual studio it is possible. Follow the instructions here:
http://www.discussweb.com/c-programming/13643-advertised-shortcuts-installers-how-avoid.html

Wait, you don't like this solution? Well, some people write a custom step in their installer or even there executable to delete the advertised shortcuts and put back regular ones using IShellLink. (Refer to the last link if you want to go this route).

So, the moral of this story kids is installers are getting scary. Or rather, the Operating System you're installing on is paranoid and suffering mental disorders. Remember, Mulder from X-files? TRUST NO ONE.

REMEMBER THE MULDER!
AND
HAPPY CODING!
Jason

Wednesday, July 15, 2009

Hard at Work

It's been awhile since a post. I thought I would throw this up here. This is a picture of me hard at work at the office.



I've been working for the past few months on about 80 updates to my 3D editor. Definately a move in the right direction. I'm currently testing the registration and update system and rewriting a better UV Mapping editor/ art tool. I'm hoping to post some tutorials here on how to use the program when it is ready for download. Beta version will be done soon.

At the office, I'm working on extracting data from a word form and putting the data in another word form. Fun stuff. I have a nice little tool that uses a rules file to convert the documents.

Remember to have lots of beverages when coding! That way you get out of your chair at least once an hour whether you want to or not. :)

Happy coding!
Jas