It is currently March 28th, 2024, 2:02 pm

[(NOT A)BUG]Double Quotes and RunCommand Parameter

Report bugs with the Rainmeter application and suggest features.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2588
Joined: March 23rd, 2015, 5:26 pm
Contact:

Re: [BUG] Double Quotes and RunCommand Parameter

Post by SilverAzide »

death.crafter wrote: September 3rd, 2021, 3:09 pm Screenshot 2021-09-03 203801.png

Powershell is behaving correctly. Rainmeter isn't. Try Parameter=echo """"I need this displayed!""""
And so your explanation for why Parameter=Write-Host "I need this displayed" works perfectly would be... what?
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm
Contact:

Re: [BUG] Double Quotes and RunCommand Parameter

Post by death.crafter »

SilverAzide wrote: September 3rd, 2021, 3:14 pm And so your explanation for why Parameter=Write-Host "I need this displayed" works perfectly would be... what?
Screenshot 2021-09-03 204615.png
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [BUG]Double Quotes and RunCommand Parameter

Post by jsmorley »

There seems to be some issue with how echo aka Write-Output is being handled with RunCommand. I can't put my finger on it. It all works as expected in the PowerShell UI, but not with RunCommand. Write-Host seems to work fine, and is what I would use.
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm
Contact:

Re: [BUG]Double Quotes and RunCommand Parameter

Post by death.crafter »

jsmorley wrote: September 3rd, 2021, 3:20 pm There seems to be some issue with how echo aka Write-Output is being handled with RunCommand. I can't put my finger on it. It all works as expected in the PowerShell UI, but not with RunCommand.
It's not only echo or Write-Output.

Try Parameter=(Get-ChildItem "C:\Program Files (x86)").Count

RunCommand is just stripping off the double quotes.

After some testing...

LMAO!!!

Try this

Code: Select all

[RunCommand]
Measure=Plugin
Plugin=RunCommand
Parameter=echo "I need this displayed!"
OutputType=ANSI
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [BUG]Double Quotes and RunCommand Parameter

Post by jsmorley »

death.crafter wrote: September 3rd, 2021, 3:27 pm It's not only echo or Write-Output.

Try Parameter=(Get-ChildItem "C:\Program Files (x86)").Count

RunCommand is just stripping off the double quotes.

After some testing...

LMAO!!!

Try this

Code: Select all

[RunCommand]
Measure=Plugin
Plugin=RunCommand
Parameter=echo "I need this displayed!"
OutputType=ANSI
The output of cmd.exe is not ANSI...
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm
Contact:

Re: [BUG]Double Quotes and RunCommand Parameter

Post by death.crafter »

jsmorley wrote: September 3rd, 2021, 3:30 pm The output of cmd.exe is not ANSI...
Ahh I see. Yeah it works fine.

Then why do the quotes in powershell parameter get removed :???:
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [BUG]Double Quotes and RunCommand Parameter

Post by jsmorley »

death.crafter wrote: September 3rd, 2021, 3:35 pm Ahh I see. Yeah it works fine.

Then why do the quotes in powershell parameter get removed :???:
Well, that's the 64,000 dollar question isn't it... Seems like somehow the "interface" between RunCommand and PowerShell is stripping them out of the Parameter. Hard to say if this is a RunCommand issue exactly, or a PowerShell issue that is only manifested due to how we pass the command to it. I'm sure Brian will look into this, but at least for now, I would recommend using 'single quotes' instead of "double quotes" in parameters to PowerShell. Just like we recommend using single quotes in Lua scripts.
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm
Contact:

Re: [BUG]Double Quotes and RunCommand Parameter

Post by death.crafter »

jsmorley wrote: September 3rd, 2021, 3:37 pm Well, that's the 64,000 dollar question isn't it... Seems like somehow the "interface" between RunCommand and PowerShell is stripping them out of the Parameter. Hard to say if this is a RunCommand issue exactly, or a PowerShell issue that is only manifested due to how we pass the command to it. I'm sure Brian will look into this, but at least for now, I would recommend using 'single quotes' instead of "double quotes" in parameters to PowerShell. Just like we recommend using single quotes in Lua scripts.
Parameter=Write-Output """"$('Can't be helped,'+' I guess!')""""
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm
Contact:

Re: [BUG]Double Quotes and RunCommand Parameter

Post by death.crafter »

Thanks a lot for looking in to this. Hope Brian finds a feasible solution.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [BUG]Double Quotes and RunCommand Parameter

Post by jsmorley »

death.crafter wrote: September 3rd, 2021, 3:44 pm Thanks a lot for looking in to this. Hope Brian finds a feasible solution.
He might, but to be honest I don't see any important distinction between single quotes that work, and double quotes that don't.

Code: Select all

[MeasureRun]
Measure=Plugin
Plugin=RunCommand
Program=Powershell
Parameter=echo 'I need this displayed'
OutputType=ANSI
Parameter=echo 'I need this displayed'
Parameter=Write-Output 'I need this displayed'
Parameter=Write-Host 'I need this displayed'

All those work identically and equally well.

I could see this being an issue worth dealing with though, as this would be a problem:

Parameter=Write-Host 'I "need" this displayed'
That would need to be:
Parameter=Write-Host 'I \"need\" this displayed'

Seems like the interface between RunCommand and PowerShell just yaks up a hairball on "quotes".
Post Reply