how to create shortcuts?

Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Thread Solved
Reply

Join Date: Feb 2008
Posts: 82
Reputation: Clawsy is an unknown quantity at this point 
Solved Threads: 4
Clawsy Clawsy is offline Offline
Junior Poster in Training

how to create shortcuts?

 
0
  #1
Oct 15th, 2008
I need little help on creating shortcut for my C# app. I want programmatically do this.
I intend to create a shortcut in startup menu folder. Maybe you could also show me how to start my app automatically using a registry entry. Thanks!
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: how to create shortcuts?

 
0
  #2
Oct 15th, 2008
And what have you found on google so far?
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 82
Reputation: Clawsy is an unknown quantity at this point 
Solved Threads: 4
Clawsy Clawsy is offline Offline
Junior Poster in Training

Re: how to create shortcuts?

 
0
  #3
Oct 15th, 2008
Thanks for reply LizR.
Of course I googled that, and I had a little problem I'll tell you now. I made a reference to "Windows Script Host Object Model", then I included IWshRuntimeLibrary and I made a button for testing, so that when I click it, process for creating the shortcut starts, like this:
  1. private WshShellClass WshShell;
  2.  
  3. private void button3_Click(object sender, EventArgs e)
  4. {
  5. // Create a new instance of WshShellClass
  6.  
  7. WshShell = new WshShellClass();
  8.  
  9. // Create the shortcut
  10.  
  11. IWshRuntimeLibrary.IWshShortcut MyShortcut;
  12.  
  13. // Choose the path for the shortcut
  14.  
  15. MyShortcut = (IWshRuntimeLibrary.IWshShortcut)WshShell.CreateShortcut(@"C:\Documents and Settings\All Users\Desktop\cLchecker.lnk");
  16.  
  17. // Where the shortcut should point to
  18.  
  19. MyShortcut.TargetPath = Application.ExecutablePath;
  20.  
  21. // Description for the shortcut
  22.  
  23. MyShortcut.Description = "Launch cLchecker";
  24.  
  25. // Location for the shortcut's icon
  26.  
  27. MyShortcut.IconLocation = Application.StartupPath + @"\cLchecker.ico";
  28.  
  29. // Create the shortcut at the given path
  30.  
  31. MyShortcut.Save();
  32. }
The problem is that I use File.AppendAllText() method to write to file and I got this error:
" 'File' is an ambiguous reference between 'System.IO.File' and 'IWshRuntimeLibrary.File' ".

It seems to be a little conflict. So, don't worry, I don't wanna lose your time with nothing; I told you now the main problem in my program. And sorry for not pointing to the exact problem. I'll go now; in 7 hours I'm back.
Last edited by Clawsy; Oct 15th, 2008 at 8:26 am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 33
Reputation: miculnegru is an unknown quantity at this point 
Solved Threads: 5
miculnegru miculnegru is offline Offline
Light Poster

Re: how to create shortcuts?

 
0
  #4
Oct 15th, 2008
use something like : System.IO.File.AppendAllText
Last edited by miculnegru; Oct 15th, 2008 at 8:35 am.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 82
Reputation: Clawsy is an unknown quantity at this point 
Solved Threads: 4
Clawsy Clawsy is offline Offline
Junior Poster in Training

Re: how to create shortcuts?

 
0
  #5
Oct 15th, 2008
It doesn't work. However thanks for reply.
Somebody else? Ideas?
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: how to create shortcuts?

 
0
  #6
Oct 15th, 2008
You dont show the code you're using so we're only guessing..

Your short cut looks like it should appear after your code above.. Whats the file bit for? something else?
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 104
Reputation: jen140 is an unknown quantity at this point 
Solved Threads: 5
jen140 jen140 is offline Offline
Junior Poster

Re: how to create shortcuts?

 
0
  #7
Jan 8th, 2009
Try using System.IO.File.Something or IWshRuntimeLibrary.File.Something.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 302
Reputation: Diamonddrake is a jewel in the rough Diamonddrake is a jewel in the rough Diamonddrake is a jewel in the rough 
Solved Threads: 36
Diamonddrake's Avatar
Diamonddrake Diamonddrake is offline Offline
Posting Whiz

Re: how to create shortcuts?

 
0
  #8
Jan 9th, 2009
what you have to do is remove "using System.IO;" from the top of your class, and everytime you need to use System.IO.File you will have to type the full namespace. problem is that when you import the namespace for the object that creates your shortcut you share its namespace scope with the "File" namespace scope of the System.IO, so removing the using block at the top of your class fixes the problem.

Happy Coding!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC