microsoft / PowerToys

Windows system utilities to maximize productivity
MIT License
110.53k stars 6.5k forks source link

PT Run can not start .lnk file #16912

Closed GrahLnn closed 8 months ago

GrahLnn commented 2 years ago

Microsoft PowerToys version

0.56.2

Running as admin

Area(s) with issue?

PowerToys Run

Steps to reproduce

image PowerToysReport_2022-03-09-13-22-00.zip

✔️ Expected Behavior

to open app use PT Run

❌ Actual Behavior

No response

Other Software

No response

crutkas commented 2 years ago

on quick look, logs don't show a failure, odd

jaimecbernardo commented 2 years ago

Hi @GrahLnn , Thanks for reporting. Could you please give some more context about what's happening and what the message says? (Can't understand this language) What application is that? Is it happening just with that application? /needinfo

jaimecbernardo commented 2 years ago

Could you please also paste those characters in a GitHub comment so that I can try to copy and use them in paths and see if that's the issue?

GrahLnn commented 2 years ago

Yes! It's starting 3 or 4 days ago, I use PTRun like usual, but PTRun can't start any application, not just this one. Then I go to this URL and double click .lnk file, it can start normally. The message says "Plugin:程序(Program) 无法启动(Could not start): C:...... .lnk". The "微信“ is same with WeChat but developing for Chinese users. Not just for this application, all application cannot use PTRun to start in this computer.

image image image about other application by use PTRun to start

jaimecbernardo commented 2 years ago

Thank you, just identified the code path... Unfortunately this code path is not logging the exception. I'll add some logs here and send you a Debug build to see if we can identify what's happening, OK? Thank you.

jaimecbernardo commented 2 years ago

By the way, is your admin user that's running PowerToys by any change a different user than the one that's logged in?

GrahLnn commented 2 years ago

Yes, it's ok. And admin user is the logging one.

jaimecbernardo commented 2 years ago

Hi @GrahLnn

Could you please try a debug build so we can get more information into what might be causing this? (It's an unsigned build , by the way) https://github.com/jaimecbernardo/PowerToys/releases/tag/add-logs-issue-16912

Please uninstall your current PowerToys installation, then install this debug build. Replicate the bug. After that, navigate in Explorer to "%LOCALAPPDATA%\Microsoft\PowerToys\PowerToys Run\Logs\0.0.1.0" It should have created a file in there with today's date.

Please upload this log file so I can take a look.

Thank you, in advance.

jaimecbernardo commented 2 years ago

/needinfo

GrahLnn commented 2 years ago

Thak you, and this is the log file after I try using this build to open application. 2022-03-10.txt

And when I first open this build the application send me this message. Hope that helps image

jaimecbernardo commented 2 years ago

Thanks for the file. Regarding that error you see, it's a known unrelated error we need to fix before release. Interesting, translating the error in the logs 没有应用程序与此操作的指定文件有关联。 gives No application is associated with the specified file for this operation. This is a link file being opened, so it's weird it's not being opened. Needs further investigation.

jaimecbernardo commented 2 years ago

I've been unable to replicate this up until now. I've decided to go debug to see what runProcess is being called with, then I'm suddenly able to replicate it. https://github.com/microsoft/PowerToys/blob/80e9fc0c43f72710737cf49b0692aee2849588ee/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Main.cs#L172-L194

If you set a breakpoint in runProcess(info) to inspect info and then continue, it replicates the error. So, this is replicating when inspecting info? For some reason inspecting it breaks it? This is pretty weird, but it's what I'm observing, if I inspect info before calling runProcess(info) it fails 🤷 @GrahLnn , might you have some software which is inspecting memory? Does any of this make sense?

jaimecbernardo commented 2 years ago

It seems the error I'm getting is unrelated. @GrahLnn gets

Exception full name  : System.ComponentModel.Win32Exception
Exception message    : An error occurred trying to start process 'c:\programdata\microsoft\windows\start menu\programs\adobe photoshop 2022.lnk' with working directory 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs'. 没有应用程序与此操作的指定文件有关联。
Exception stack trace:
   at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
   at Microsoft.Plugin.Program.Main.StartProcess(Func`2 runProcess, ProcessStartInfo info)
Exception source     : System.Diagnostics.Process
Exception target site: Boolean StartWithShellExecuteEx(System.Diagnostics.ProcessStartInfo)
Exception HResult    : -2147467259

While I get :

Exception full name  : System.InvalidOperationException
Exception message    : The Process object must have the UseShellExecute property set to false in order to use environment variables.
Exception stack trace:
   at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
   at Microsoft.Plugin.Program.Main.StartProcess(Func`2 runProcess, ProcessStartInfo info) in D:\prog\janeasystems\PowerToys\src\modules\launcher\Plugins\Microsoft.Plugin.Program\Main.cs:line 186
Exception source     : System.Diagnostics.Process
Exception target site: Boolean StartWithShellExecuteEx(System.Diagnostics.ProcessStartInfo)
Exception HResult    : -2146233079

My error seems to be caused by the fact that inspecting the ProcessStartInfo struct will initialize the Environment Variables collection.

jaimecbernardo commented 2 years ago

It's not clear why you are getting a "No application is associated with the specified file for this operation." though.

This does seem to be an issue with the system rather than the code, since the shell should be able to execute link files.

Do you have anything set for .lnk on the Choose default apps by file type in Settings? image

Might it be that some settings for Program files are not correctly set in the registry? (taken from https://stackoverflow.com/questions/54225771/c-shellexecute-specifically-not-opening-lnk-files) image

/needinfo

GrahLnn commented 2 years ago

Thank you for helping, I checked this .lnk default seting and no app in there, then I following this to change registry it's still not get fix. image image image

jaimecbernardo commented 1 year ago

It's very weird, but explorer is unable to open link files for your. Perhaps it's one of these other keys?

image

jtmathes commented 1 year ago

I am having this same issue on v0.64.1. Shortcut (.lnk) files are found by both the Search and Program plugins, making for duplicate entries. Using the Search plugin result opens the correct folder in Windows Explorer, but using the Program plugin result results in an error window, as shown below. I have no issues opening or using Shortcut files otherwise.

image

stefansjfw commented 8 months ago

@GrahLnn @jtmathes Does this still happen with the latest version of PowerToys? /needinfo

microsoft-github-policy-service[bot] commented 8 months ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 5 days. It will be closed if no further activity occurs within 5 days of this comment.