Unable to set TargetPath when create shortcut for a file

AnilkumarM 41 Reputation points
2021-04-07T07:34:25.807+00:00

I am trying to create a Shortcut .lnk file for a file. but I unable to set the target path. this is my target path C:\TeklaStructures\2020.0\nt\bin\TeklaStructures.exe -I "C:\TeklaStructures\DowFirm\TS2020\Imperial\EngBypass.ini" "C:\TeklaStructures\NewModel"

this is my code

 WshShell wsh = new WshShell();
                IWshShortcut MyShrotcut = (IWshShortcut)wsh.CreateShortcut(ModelLinkFile);
                MyShrotcut.TargetPath = "C:\TeklaStructures\2020.0\nt\bin\TeklaStructures.exe -I \"C:\TeklaStructures\DowFirm\TS2020\Imperial\EngBypass.ini\" \"C:\TeklaStructures\NewModel\"";
                MyShrotcut.Save();

Thanks in advance.
Anilkumar

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,223 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 112.1K Reputation points
    2021-04-07T07:50:30.867+00:00

    Try this string:

    MyShrotcut.TargetPath = @"C:\TeklaStructures\2020.0\nt\bin\TeklaStructures.exe -I ""C:\TeklaStructures\DowFirm\TS2020\Imperial\EngBypass.ini"" ""C:\TeklaStructures\NewModel""";
    

    Also check this:

    MyShrotcut.TargetPath = @"C:\TeklaStructures\2020.0\nt\bin\TeklaStructures.exe";
    MyShortcut.Arguments = @"-I ""C:\TeklaStructures\DowFirm\TS2020\Imperial\EngBypass.ini"" ""C:\TeklaStructures\NewModel""";
    
    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful