Nitsua

Hi All,

I am looking for a way to create an shortcut that points to a program located on a local server. I am able to do this through code using this:

Code Snippet

//----------------------------------------------------------------------------//

// Place Shortcuts Inside Start Menu and On Desktop //

//----------------------------------------------------------------------------//

string DesktopPath = @"C:\Documents and Settings\All Users\Desktop\Shortcut.lnk";

string StartMenuPath = @"C:\Documents and Settings\All Users\Start Menu\Programs\Program\Shortcut.lnk";

WshShell = new WshShellClass();

// Create the shortcut

IWshRuntimeLibrary.IWshShortcut DesktopShortcut, StartMenuShortcut;

// Choose the path for the shortcut

DesktopShortcut = (IWshRuntimeLibrary.IWshShortcut)WshShell.CreateShortcut(DesktopPath);

StartMenuShortcut = (IWshRuntimeLibrary.IWshShortcut)WshShell.CreateShortcut(StartMenuPath);

// Where the shortcut should point to

DesktopShortcut.TargetPath = @"\\Server\Program\Program.exe";

StartMenuShortcut.TargetPath = @"\\Server\Program\Program.exe";

// Description for the shortcut

DesktopShortcut.Description = "Program Version";

StartMenuShortcut.Description = "Program Version";

// Specify location of shortcut's icon

DesktopShortcut.IconLocation = @"\\Server\Program\Icon.ico";

StartMenuShortcut.IconLocation = @"\\Server\Program\Icon.ico";

// Create the shortcut at the given path

DesktopShortcut.Save();

System.IO.Directory.CreateDirectory(@"C:\Documents and Settings\All Users\Start Menu\Programs\Program\");

StartMenuShortcut.Save();

...but I am looking for a way to have the installer automatically create these shortcuts. Similarly to how you can create shortcuts to .exe located inside your project. I am using Visual Studio 2005. Is this possible If so it would allow me to avoid some Custom Actions, which would be nice.

Thanks in advance.



Re: ClickOnce and Setup & Deployment Projects Need Help Creating Custom Shortcuts

Gavin Jin - MSFT

Hi£¬

ClickOnce does not have the ability to create desktop shortcuts. But you can try following way to do it.

Here's a great post on how to add a desktop shortcut to ClickOnce Deployed Application. (Scott Schecter's post)
http://blog.scottschecter.net/TheZenOfTheClickOnceDeployedApplicationDesktopShortcut.aspx

Here's the version of this solution in VB. (Julia Lerman's post)
http://blog.ziffdavis.com/devlife/archive/2006/07/28/42695.aspx

For more information,check this link

http://geekswithblogs.net/murraybgordon/archive/2006/10/04/93203.aspx

http://blog.ziffdavis.com/devlife/archive/2006/05/28/41839.aspx

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=137777&SiteID=1

With Regards






Re: ClickOnce and Setup & Deployment Projects Need Help Creating Custom Shortcuts

Nitsua

I don't think I am doing a Clickonce deployment. Also, the shortcut I wish to create is not for the application being deployed.

Is there a way to package up a pre-existing shortcut inside of the installer I tried put couldn't get the shortcut to stay in the projects File System.

Thanks for the help.