public void CreateShortcut(string shortcutFileName) { // From: http://stackoverflow.com/questions/234231/creating-application-shortcut-in-a-directory // WshShortcut Object Properties and Methods: http://msdn.microsoft.com/en-us/library/f5y78918.aspx dynamic shell = ComUtility.CreateInstance("WScript.Shell"); try { var link = shell.CreateShortcut(shortcutFileName); try { link.TargetPath = ApplicationInfo.ExecutableFile; link.Arguments = this.BuildCommandLine(false); link.Description = "Opens the \"" + this.Gizmo.GizmoName + "\" gizmo."; link.Save(); } finally { ComUtility.FinalRelease(link); } } finally { ComUtility.FinalRelease(shell); } }
public void CreateAndReleaseTest() { // WshShortcut Object Properties and Methods: http://msdn.microsoft.com/en-us/library/f5y78918.aspx dynamic?shell = ComUtility.CreateInstance("WScript.Shell"); Assert.IsNotNull(shell); try { var link = shell !.CreateShortcut("TestShortcut.lnk"); try { link.TargetPath = ApplicationInfo.ExecutableFile; link.Arguments = "/Argument=1"; link.Description = "Testing a shortcut"; // Don't save the link for this test: link.Save(); } finally { ComUtility.FinalRelease(link); } } finally { ComUtility.FinalRelease(shell); } }