Mathias has
provided the crucial pointer:
The PowerShell CLI's own parameters - such as -NoLogo
in your case, and often -ExecutionPolicy
, -NoProfile
and -NoExit
- must be placed before any command or script file to invoke and its subsequent pass-through arguments.
Anything that follows -File
or -Command
- or in the absence of either - the first argument that isn't a CLI parameter[1] is considered the script file or command to execute, with all subsequent arguments getting passed through, whatever they are.
Therefore:
powershell.exe neofetch -nologo
is the same as powershell.exe -Command neofetch -nologo
and passes -nologo
to neofetch
instead of to PowerShell, which presumably causes it to fail and exit right away.
You would have to place -nologo
before neofetch
to work as intended; however, -nologo
isn't actually necessary in your case (with -Command
and -File
, -nologo
is implied, except if -File
is combined with -NoExit
); to demonstrate the correct syntax with -NoExit
instead:
# -NoExit (as well as any other PowerShell CLI parameters) must come *first*.
# Same as:
# powershell.exe -NoExit -Command neofetch
powershell.exe -NoExit neofetch
In the context of your JSON file:
"commandline": "%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -NoExit neofetch",
[1] Note that the CLIs of the two PowerShell editions have different defaults: powershell.exe
, the Windows PowerShell CLI,, defaults to -Command
, whereas pwsh
, the PowerShell (Core) CLI, defaults to -File
. See this answer for when to use -File
vs. -Command
.