Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Столкнулся с проблемой запуска программы через ярлык(.lnk)
с помощью ProcessStartInfo Process

Получается так что запуская ярлык(.lnk) программы
"C:\Program Files\Notepad++\notepad++.exe" ,
Process отказываеться запускать программу.

Если запустить программу по прямому пути
"C:\Program Files\Notepad++\notepad++.exe" ,
Process запускает программу.


Translation:
Faced the problem of starting the program through a shortcut (.lnk)
using ProcessStartInfo Process

It turns out that by launching the shortcut (.lnk) of the program
"C: \ Program Files \ Notepad ++ \ notepad ++. Exe",
Process refuses to run the program.

If you run the program in a direct way
"C: \ Program Files \ Notepad ++ \ notepad ++. Exe",
Process starts the program.

What I have tried:

В качестве альтернативы запуска был использован AIMP.
Process запускает программу как через ярлык(.lnk) так и по прямому пути
"C:\Program Files (x86)\AIMP\AIMP.exe"


procStart.7z / Облако Mail.ru[^]

procStart.7z — Yandex.Disk[^]


Translation:
AIMP was used as an alternative to launch.
Process launches the program both through the shortcut (.lnk) and along the direct path
"C: \ Program Files (x86) \ AIMP \ AIMP.exe"
Posted
Updated 28-May-20 15:56pm
v5
Comments
ZurdoDev 27-May-20 14:57pm    
English
Maciej Los 27-May-20 15:48pm    
This is English forum. Please, use English.
BTW: No one would like to download suspicious files.
Mesartim 28-May-20 22:45pm    
"BTW: No one would like to download suspicious files."
Why then do you need antivirus programs if you are afraid to download. It would be even more convenient to view the code by downloading the source code and open it in the studio.

Try this:
C#
Process proc = new Process();
proc.StartInfo.FileName = @"c:\myShortcut.lnk";
proc.UseShellExecute = false;
proc.Start();
 
Share this answer
 
Comments
Pete O'Hanlon 28-May-20 3:22am    
My 5
Maciej Los 28-May-20 3:59am    
Thank you, Pete.
Quote:
Apparently Process cannot distinguish the location of the file if you run the program through a shortcut (.lnk)
Because with the path to the file "C: \ Program Files" in the shortcut (.lnk) in the x64 system
Process will return the value "C: \ Program Files (x86)" and give the error "The specified path does not exist."
what does not appear in the message for the shortcut processInfo.ErrorDialog = true;
img-2020-05-28-08-30-40.png — Yandex.Disk[^]


string program_files_folder = Environment.Is64BitProcess ?
    Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) :
    Environment.GetEnvironmentVariable("ProgramW6432");
string programFilesX86 = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900