Skip to content

KBM, Keyboard Manager, Can't run PowerShell (.ps1) files with shortcut remapping #37412

Open
@MaixGit

Description

Microsoft PowerToys version

0.88.0

Installation method

Microsoft Store

Running as admin

None

Area(s) with issue?

Keyboard Manager

Steps to reproduce

I used to have my custom scripts in .bat files which worked fine when starting them with shortcuts, but I've moved to using PowerShell scripts and PowerToys has an issue with the .ps1 files.

Image

Having a shortcut mapped to run a .ps1 file as above, results in the following error notification:

Image

And having the .ps1 file set to run with elevated privileges in the shortcut remapper window results in this error and then the usual failed to start notification once I've clicked ok:

Image

I've also tried changing the "start in" directory, and visibility options for the shortcut, also running a different .ps1 file in a different directory, running PowerToys as admin, all of which changed nothing.
I'm using PowerShell 7.5.0 and Windows Terminal, but I also tried with the integrated Windows PowerShell and without Windows Terminal, both of which changed nothing.

Here's a snippet from the log:

[2025-02-13 01:08:57.201267] [p-4716] [t-7632] [trace] PowerToys_KeyboardManager_Event_Settings event was signaled
[2025-02-13 01:08:57.201291] [p-4716] [t-7632] [trace] SettingsHelper::LoadSettings()
[2025-02-13 01:08:58.382429] [p-4716] [t-1084] [trace] ChordKeyboardHandler:returning..
[2025-02-13 01:08:58.382473] [p-4716] [t-8296] [trace] ChordKeyboardHandler:Restart Explorer.ps1, trying to run C:\Users\Bosh\Downloads\Restart Explorer.ps1
[2025-02-13 01:08:58.387834] [p-4716] [t-8296] [trace] ChordKeyboardHandler:Restart Explorer.ps1, already running, pid:0, alreadyRunningAction:0
[2025-02-13 01:08:58.387932] [p-4716] [t-8296] [info] run_non_elevated with params= 
[2025-02-13 01:08:58.388128] [p-4716] [t-8296] [error] CreateProcessW() failed. %1 is not a valid Win32 application.
[2025-02-13 01:08:58.388236] [p-4716] [t-8296] [trace] ChordKeyboardHandler:toastXml <toast><visual><binding template="ToastGeneric"><text>Error starting Restart Explorer.ps1</text><text>The application might not have started.</text></binding></visual></toast>

✔️ Expected Behavior

Execute .ps1 files when activating keyboard shortcut

❌ Actual Behavior

Error with starting the .ps1 files when activating keyboard shortcut

Other Software

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions