Is there a way to run a powershell command when opening the run box (Windows+R)?
I'd like to just start typing get-process for example and have it execute that command in powershell and display the result (basically opening it and not closing it).
I know you can type "powershell /noexit get-process" to achieve this, but I'd like to know if there's a way the Run box realizes it's a powershell command and all I have to type is the command: get-process.
No, there is no way to make Windows+R understand PowerShell commands directly.
One workaround is to create a batch file with content like this:
@echo off
%systemroot%\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -noprofile -noLogo "%1 %2 %3 %4 %5 %6 %7 %8"
name it p.cmd
and put it in a location that is in your path.
Now you can do:
start with p
then the PowerShell command you want to execute.
Might be a bit too late, but you are able to run CMD commands through the run box, and then again PowerShell commands through CMD. By utilizing this you can type:
cmd /k PowerShell.exe "Your PowerShell command"
where the /k
can be changed wirh /c
if you don't want the CMD-window to stay open.
In the end it could look something like this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With