I am creating a shortcut using WshShell VS2010 .Net 4 and ant to be able to create a target path that has a reference to AccessRuntinme then our application. This is what I have so far with no errors untill I run the program and click the button.
private void CreateShortCut64()
{
object shDesktop = (object)"Desktop";
WshShell shell = new WshShell();
string shortcutAddress = (string)shell.SpecialFolders.Item(ref shDesktop) + @"\LinkName.lnk";
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutAddress);
string targetPath64 = "\"C:\\Program Files (x86)\\Microsoft Office\\Office12\\MSACCESS.EXE\" \"C:\\Program Files (x86)\\My Program\\Prog.accdr\"";
shortcut.Description = "Program";
shortcut.Hotkey = "Ctrl+Shift+A";
shortcut.TargetPath = targetPath64;
shortcut.IconLocation = "c:\\Program Files (x86)\\My Program\\" + @"\Prog.ico";
shortcut.Save();
}
The above example works fine if I leave out the reference to Access Runtime and just have My Program as the target but I want to have both in the target which works fine when you edit the target through windows.
Any help will be much appreciated.
I suspect that it is because you are not setting MS Access to run-time mode:
Edit re comments
I tested with MS Access 2010 x64 installed, so the path names are different, otherwise the code is pretty similar to the OP.