0

c# When I run this command, it works:

Process.Start("C:\\Users\\Matan\\source\\repos\\SECSManager\\run_dir\\net5.0-windows\\SECSUI");

but when I try to run a shortcut: Process.Start("C:\\Users\\Matan\\source\\repos\\SECSManager\\run_dir\\net5.0-windows\\SECSUI - Shortcut");

the following error occurs:

An error occurred trying to start process 'C:\Users\Matan\source\repos\SECSManager\run_dir\net5.0-windows\SECSUI - Shortcut' with working directory 'C:\Users\Matan\source\repos\ConsoleApp2\bin\Debug\net6.0'. The system cannot find the file specified.

is it Possible to execute a shorcut?

MatanCode
  • 37
  • 3
  • There are only a handful of extensions that are recognized as "executable" and therefore allow you to run files using them without specifying the extension; `.lnk` is not one of them. Appending it explicitly to your file should make `Process.Start` do the right thing, though (disclaimer: not tested); depending on your .NET version you may need to explicitly specify `UseShellExecute = true`. Confusingly, Explorer leaves off the extension of shortcut files even if otherwise configured to show extensions. – Jeroen Mostert Nov 21 '22 at 12:20

0 Answers0