visual studio - add specific URL to shortcut target C# -


trying create few different shortcuts various urls on desktop following method:

public static void createshortcutwithurl(     string shortcutname, string shortcutpath, string targetfilelocation) {     var shortcutlocation = path.combine(shortcutpath, shortcutname + ".lnk");     var shell = new wshshell();     var shortcut = (iwshshortcut)shell.createshortcut(shortcutlocation);      // description of shortcut     //shortcut.description = "my shortcut description";      // icon of shortcut     //shortcut.iconlocation = @"c:\myicon.ico";      // path of file launch when shortcut run     shortcut.targetpath = $" \" {targetfilelocation} \" https://www.somewebsite.com";      shortcut.save(); } 

it errors out if try adding targetfilelocation.

i use this:

createshortcutwithurl(     "my shortcut",     environment.getfolderpath(environment.specialfolder.desktop),     @"c:\program files (x86)\internet explorer\iexplore.exe"); 

if change line in method completes without error:

shortcut.targetpath = targetfilelocation ;  

the shortcut put on desktop - without additional https://www.somewebsite.com added target - opens browser without directing website.

i'm trying create few shortcuts open explorer, make navigate particular websites.

two things wrong:

  1. you don't need "" around path iexplore.exe
  2. you can't add website address path, must argument

change following code:

shortcut.targetpath =" \" "+targetfilelocation+ " \" " + " https://www.somewebsite.com" ;  

to this:

shortcut.targetpath = targetfilelocation; shortcut.arguments = @"https://www.google.com"; 

the rest of method fine is.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -