PDA

View Full Version : CreateShortcut bug when Icon is in an Exe different from the Target?



DanCooperstock
10-16-2007, 02:07 PM
I am running the following statement to create a shortcut:

Shell.CreateShortcut(_DesktopFolder, "DONATION", SessionVar.Expand("%AppFolder%\\RunDonation.exe"),
"", SessionVar.Expand("%AppFolder%"), SessionVar.Expand("%AppFolder%\\donation.exe"), 0, SW_SHOWNORMAL, nil,
"My Comment")

The reason I'm doing this is that RunDonation.exe, the Target, is a small runner app that I am code signing, which runs the real app donation.exe. (For technical reasons, I can't code sign donation.exe.) But the icon is in donation.exe.

What happens when I run this is that the "DONATION" shortcut is created, but the target fo that shortcut is donation.exe, not RunDonation.exe.

This seems like a bug. Any way to work around it?

Thanks.

DanCooperstock
10-16-2007, 04:41 PM
I haven't resolved the bug per se, but I did get around it by creating the shortcut from the normal UI, in the Shortcut tab of the properties window for the desired target. It was basically the same setup there (icon in a different executable from the target), and it worked fine.

The reason I was doing the shortcut in code was that I only needed the target to be RunDonation.exe in Windows Vista, 2003 or Higher, and the shortcut could still be my regular executable, donation.exe, for Windows XP and 2000. In fact, RunDonation.exe is only installed on Vista etc. This arrangement did mean that I still had to create the shortcut for donation.exe in code (if it was Windows XP or 2000), but there was nothing weird about that shortcut creation, so it worked fine.