ContextMenuForWindows11 icon indicating copy to clipboard operation
ContextMenuForWindows11 copied to clipboard

Windows instantly closing when using pwsh exe

Open drandarov-io opened this issue 8 months ago • 5 comments

I'm trying to create an entry for a Powershell command, but when I try it, it instantly closes the window:

I can see the command for just a split second. In this screenshot I also tried adding Read-Host to keep the window open, but there is no difference:

Image ^^^ This disappears after a split seconds

Image

I also tried it with just ls:

Image ^^^ This disappears after a split seconds

Image

drandarov-io avatar May 28 '25 08:05 drandarov-io

try add -noexit sample: https://github.com/ikas-mc/ContextMenuForWindows11/discussions/173

ikas-mc avatar May 28 '25 12:05 ikas-mc

Thanks, I somehow missed the samples, looked only in Issues.

-noe -c ffprobe '{path}' is my final solution.

I also got hung up on the ", because in the sample it's \\\", which means it needs to be \" in the GUI which took me a bit to understand.

drandarov-io avatar May 28 '25 12:05 drandarov-io

One more thing: Do you know why pwsh -c { } does not work. It only prints the command. Since this usually works in the Terminal?

The issue is that ' ' and \" \" get resolved beforehand I believe and this causes files with spaces in them to fail. { } usually prevents this.

It's probably because { } are not escaped. Are they escapable? \{ \} doesn't seem to work.


For testing I put two spaces in the file name Video .AV1.mkv. {path} gets resolved to Video .AV1.mkv however with only one space. This seems to be a separate issue.

Feel free to close this issue. The handling of double-spaces is pretty niche anyway.

drandarov-io avatar May 28 '25 13:05 drandarov-io

This may be the logic of PowerShell itself, I'm not familiar with PowerShell, but it seems like {} can't be escaped

ikas-mc avatar May 28 '25 13:05 ikas-mc