Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Run Programs] URL shortcuts are limited to certain protocols #33381

Open
xieve opened this issue Jun 14, 2024 · 6 comments
Open

[Run Programs] URL shortcuts are limited to certain protocols #33381

xieve opened this issue Jun 14, 2024 · 6 comments
Labels
Idea-Enhancement New feature or request on an existing product Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams Product-PowerToys Run Improved app launch PT Run (Win+R) Window

Comments

@xieve
Copy link

xieve commented Jun 14, 2024

Microsoft PowerToys version

0.81.1

Installation method

Chocolatey

Running as admin

Yes

Area(s) with issue?

PowerToys Run

Steps to reproduce

Create URI shortcut for specific Obsidian vault:

image

Place this shortcut in:

C:\Users\<current user>\AppData\Roaming\Microsoft\Windows\Start Menu and/or
C:\Users\<current user>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs and/or
C:\Users\<current user>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Obsidian and/or
C:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu and/or
C:\Users\<current user>\Desktop

Open PowerToys Run

image

No results. Sanity check:

image

These URL shortcuts work and are located in:
C:\Users\<current user>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Steam

They look like this:

image

If I don't restrict results to the programs plugin, I get results from Everything:

image

However the thumbnail/icon is not shown and the file extension is.

✔️ Expected Behavior

I want this shortcut to show up like any other program.

❌ Actual Behavior

Shortcut only shows up as file without icon.

Other Software

Obsidian v1.6.3

@xieve xieve added Issue-Bug Something isn't working Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams labels Jun 14, 2024
Copy link

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@xieve
Copy link
Author

xieve commented Jun 14, 2024

Huh. The bot was better at searching than me. Duplicate of #31322.

@xieve xieve closed this as completed Jun 14, 2024
@xieve xieve changed the title [Run Programs] Manually created URL shortcut is not being picked up [Run Programs] URL shortcuts are limited to certain protocols Jun 14, 2024
@xieve
Copy link
Author

xieve commented Jun 14, 2024

Reopening as a general-scope issue about being limited to two specific URI schemes. I don't see why PT Run should be hard-codedly limited to only steam and epic games URL shortcuts. This should at the very least be configurable.

cf.

private static readonly Regex InternetShortcutURLPrefixes = new Regex(@"^steam:\/\/(rungameid|run|open)\/|^com\.epicgames\.launcher:\/\/apps\/", RegexOptions.Compiled);
// This function filters Internet Shortcut programs
private static Win32Program InternetShortcutProgram(string path)
{
try
{
// We don't want to read the whole file if we don't need to
var lines = FileWrapper.ReadLines(path);
string iconPath = string.Empty;
string urlPath = string.Empty;
bool validApp = false;
const string urlPrefix = "URL=";
const string iconFilePrefix = "IconFile=";
foreach (string line in lines)
{
// Using OrdinalIgnoreCase since this is used internally
if (line.StartsWith(urlPrefix, StringComparison.OrdinalIgnoreCase))
{
urlPath = line.Substring(urlPrefix.Length);
if (!Uri.TryCreate(urlPath, UriKind.RelativeOrAbsolute, out Uri _))
{
ProgramLogger.Warn("url could not be parsed", null, MethodBase.GetCurrentMethod().DeclaringType, urlPath);
return InvalidProgram;
}
// To filter out only those steam shortcuts which have 'run' or 'rungameid' as the hostname
if (InternetShortcutURLPrefixes.Match(urlPath).Success)
{
validApp = true;
}
}
else if (line.StartsWith(iconFilePrefix, StringComparison.OrdinalIgnoreCase))
{
iconPath = line.Substring(iconFilePrefix.Length);
}
// If we resolved an urlPath & and an iconPath quit reading the file
if (!string.IsNullOrEmpty(urlPath) && !string.IsNullOrEmpty(iconPath))
{
break;
}
}
if (!validApp)
{
return InvalidProgram;
}
try
{
return new Win32Program
{
Name = Path.GetFileNameWithoutExtension(path),
ExecutableName = Path.GetFileName(path),
IcoPath = iconPath,
FullPath = urlPath,
UniqueIdentifier = path,
ParentDirectory = Directory.GetParent(path).FullName,
Valid = true,
Enabled = true,
AppType = ApplicationType.InternetShortcutApplication,
};
}
catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException)
{
ProgramLogger.Warn($"|Permission denied when trying to load the program from {path}", e, MethodBase.GetCurrentMethod().DeclaringType, path);
return InvalidProgram;
}
}
catch (Exception e)
{
ProgramLogger.Exception($"|An unexpected error occurred in the calling method InternetShortcutProgram at {path}", e, MethodBase.GetCurrentMethod().DeclaringType, path);
return InvalidProgram;
}
}

@xieve xieve reopened this Jun 14, 2024
@Aaron-Junker Aaron-Junker added Idea-Enhancement New feature or request on an existing product Product-PowerToys Run Improved app launch PT Run (Win+R) Window labels Jun 15, 2024
@Aaron-Junker
Copy link
Collaborator

Aaron-Junker commented Jun 15, 2024

@htcfreek, do you know why it is limited only to these two protocols?

@htcfreek
Copy link
Collaborator

This eas not explicitly forced. It is by design. We need to decide if it is an application/webpage or not. So we only accept specific shortcuts which is currently apps, webpages and steam.

So we need an enhancement for the plugin code to support/allow these shortcuts.

@htcfreek htcfreek removed the Issue-Bug Something isn't working label Jun 16, 2024
@xieve
Copy link
Author

xieve commented Jun 21, 2024

This eas not explicitly forced. It is by design. We need to decide if it is an application/webpage or not. So we only accept specific shortcuts which is currently apps, webpages and steam.

So we need an enhancement for the plugin code to support/allow these shortcuts.

  1. Webpages are not allowed. I have a lot of .url shortcuts to webpages, none of which show up as programs. This is only logical, since https:// shortcuts are not among the two filtered types in the code snippet I linked above.
  2. What other types of .url shortcuts are there that would not be desirable to index? I can't think of any.

My rationale is as follows:

  • If there is a shortcut in the Start Menu, it is intended to be handled like a program.
  • This applies especially to any custom URI scheme that is not https://, file:// or similar.
  • The Windows Start Menu itself does not differentiate between types of shortcuts at all. For example, here is that same .url shortcut I created in the process documented above, appearing in the Windows Start Menu search.

image

In my opinion, PT Run should never display less local results than the Start Menu in the default configuration.

Reading up on the history of the filter, URL shortcuts were added to support Steam and Epic Games games specifically. I believe this support should be broadened, and the filter removed or made configurable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Idea-Enhancement New feature or request on an existing product Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams Product-PowerToys Run Improved app launch PT Run (Win+R) Window
Projects
None yet
Development

No branches or pull requests

3 participants