Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I execute a powershell script by a shortcut key?

So I have successfully bound a key to open this script:

shortcut settings

But the way to run that script with PowerShell is to right-click it and go Open with PowerShell. Using the key binding, it just opens it normally (so with notepad).

How can I make it so it opens with PowerShell from that binding?

like image 599
Thomas Adnum Avatar asked Aug 31 '25 10:08

Thomas Adnum


1 Answers

You already have a lnk that points to your script file. Make that point to PowerShell and pass your file as a parameter. Assuming your file is located in C:\PSScripts you would have to set the Target of the lnk to

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command "& C:\PSScripts\Display Off.ps1" -NoLogo -NonInteractive -NoProfile

enter image description here

like image 173
Bill Tür stands with Ukraine Avatar answered Sep 03 '25 02:09

Bill Tür stands with Ukraine