1
I've been recently using Blender, but it seems that some errors are only printed to the console. If I manually open PowerShell and run Blender from there, it works fine and I can read the error messages. However, I'd like to change my shortcut to do this for me.
Basically I'm trying to run an arbitrary command in PowerShell, from a shortcut. I found this question which hasn't helped; I have tried putting these in the "Target" section, to no success:
powershell "C:\Program Files\Blender Foundation\Blender\blender.exe"
powershell Invoke-Expression "C:\Program Files\Blender Foundation\Blender\blender.exe"
Invoke-Expression "C:\Program Files\Blender Foundation\Blender\blender.exe"
The first two pop open a black command window for a moment which immediately disappears, and also powershell
is replaced with C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
when I hit "Apply" but I figured I'd include the shortened version here.
The third says "The name 'Invoke-Expression' specified in the Target box is not valid.".
I also came across this question, so I tried adding -NoExit -Command
:
powershell -NoExit -Command "C:\Program Files\Blender Foundation\Blender\blender.exe"
This pops up a window with the message C:\Program : The term 'C:\Program' is not recognized as the name of a cmdlet, function, script file, or operable program
. I find it strange that it gets stuck at the space even though I quoted the path. I also tried using a set of single quotes too:
powershell -NoExit -Command '"C:\Program Files\Blender Foundation\Blender\blender.exe"'
powershell -NoExit -Command "'C:\Program Files\Blender Foundation\Blender\blender.exe'"
This just results in a PowerShell window opening to a command prompt, printing out the command I wished to execute instead of actually executing it:
C:\Program Files\Blender Foundation\Blender\blender.exe
PS C:\Program Files\Blender Foundation\Blender>
How do I run a command / executable in PowerShell from a shortcut?
Why Powershell in first choice? Why not try with Command Prompt with
/K
option? – Biswapriyo – 2019-10-07T06:31:59.963I'd prefer to use the more modern tool. CMD is ancient. – Aaron Franke – 2019-10-07T06:32:58.700
1For your question, you only want to see the error message. So, the shell (cmd or powershell) does not matter in this situation. – Biswapriyo – 2019-10-07T06:36:10.260
I want to learn, not simply have my problem solved. I want to know how to use PowerShell to launch other arbitrary commands too in the future, because I know this skill will come in handy. Please only reply if you will help answer the question. – Aaron Franke – 2019-10-07T06:47:11.023
Don't feel too bad towards @Biswapriyo. We really do try to help. Most people here are not advanced users, and Powershell is an advanced tool. I too would ask the very same question because in the end, the difference will not matter, but cmd is way easier to setup. With Command Prompt, you can just make a .bat or .cmd file and it works out of the box. With PowerShell, you make a .ps1 file, then right-click it to run, or make a .cmd file to launch powershell and execute the ps1 file. It is also possible to create a shortcut to launch the ps1 file or the command, but that is even harder. – LPChip – 2019-10-07T07:17:11.193