It is currently April 18th, 2024, 8:32 pm

RunCommand

Share and get help with Plugins and Addons
User avatar
Grim
Posts: 56
Joined: February 5th, 2014, 3:44 pm
Location: Canada

Re: RunCommand 1.0

Post by Grim »

Hey Brian, wondering if you can maybe help? :sos:

I've reached :headbang: point.

I'm trying to get RunCommand to execute PowerShell commands. Here's my testing code.

Code: Select all

[Rainmeter]
Update=1000
BackgroundMode=2
BevelType=1
BackgroundMargins=5,5,5,5
DynamicWindowSize=1
SolidColor=0,0,0,169

[Metadata]
Name=RunCommand Testing
Author=Grim
Version=2014.08.12
License=None
Information=Testing RunCommand with PowerShell commands

;[MeasureAutoUpdate]
;Measure=Calc
;Formula=1
;UpdateDivider=5
;OnUpdateAction=[!CommandMeasure MeasureStatus Run]

[MeasureStatus]
Measure=Plugin
Plugin=RunCommand
;Program="powershell.exe"
;Parameter="-command "& {get-process | sort ws -descending | select -first 10}""
Parameter=""powershell.exe -command "get-process | sort ws -descending | select -first 10"""
OutputFile=<InvalidFile>.tmp
OutputType=ANSI
;State=Show
FinishAction=[!UpdateMeasure #CURRENTSECTION#][!SetOption MeterStatus MeasureName MeasureStatus][!UpdateMeter MeterStatus][!Redraw]

[MeterLabel]
Meter=String
X=5
Y=5R
FontColor=FFFFFF
Text="Powershell command Output (Click _HERE_ to RUN):"
LeftMouseUpAction=[!CommandMeasure MeasureStatus Run]

[MeterStatus]
Meter=STRING
MeasureName=MeasureStatus
X=5
Y=R
FontColor=00FF00
FontFace=Lucida Console
The above code only works if I open Task Manager and then End Process the powershell.exe in the list. Same thing if I enable the State=Show param and then subsequently CLOSE the cmd window that pops up.

I've tried all sorts of cmd and powershell command line options to try and get this thing to just output, but it's being stubborn.

Do I have my !Bangs wrong? If not, got any ideas?

Thanks in advance and cheers. :beer:
User avatar
Brian
Developer
Posts: 2678
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: RunCommand 1.0

Post by Brian »

Believe it or not, this is a bug with Powershell. Apparently Powershell does not like redirected input and/or output.

However, there is a workaround. Add the following to your command: -inputformat none.

Code: Select all

[Rainmeter]
Update=1000
BackgroundMode=2
BevelType=1
BackgroundMargins=5,5,5,5
DynamicWindowSize=1
SolidColor=0,0,0,169

[Metadata]
Name=RunCommand Testing
Author=Grim
Version=2014.08.12
License=None
Information=Testing RunCommand with PowerShell commands

;[MeasureAutoUpdate]
;Measure=Calc
;Formula=1
;UpdateDivider=5
;OnUpdateAction=[!CommandMeasure MeasureStatus Run]

[MeasureStatus]
Measure=Plugin
Plugin=RunCommand
Program="powershell.exe"
Parameter="-inputformat none -command "& {get-process | sort ws -descending | select -first 10}""
OutputFile=<InvalidFile>.tmp
OutputType=ANSI
FinishAction=[!UpdateMeasure #CURRENTSECTION#][!SetOption MeterStatus MeasureName MeasureStatus][!UpdateMeter MeterStatus][!Redraw]

[MeterLabel]
Meter=String
X=5
Y=5R
FontColor=FFFFFF
Text="Powershell command Output (Click _HERE_ to RUN):"
LeftMouseUpAction=[!CommandMeasure MeasureStatus Run]

[MeterStatus]
Meter=STRING
MeasureName=MeasureStatus
X=5
Y=R
FontColor=00FF00
FontFace=Lucida Console
Also, thanks for sharing that redistributable package. I didn't even think of that being the problem. Watch for a new version of the plugin that will hopefully get rid of that problem from now on.

-Brian
User avatar
Grim
Posts: 56
Joined: February 5th, 2014, 3:44 pm
Location: Canada

Re: RunCommand 1.0

Post by Grim »

Thank you sir! Couldn't get PowerShell to reproduce the behavior so didn't think to attribute it to that kind of bug. Will have to keep an eye on the PowerShell bugs now.

Now time to go play...
:D
..and your welcome. Glad I could help.
Wallboy
Posts: 70
Joined: October 1st, 2012, 4:53 am

Re: RunCommand 1.0

Post by Wallboy »

Great plugin! I have been using it to run a image resize command line program with State=Hide, to hide the ugly command line window popup. Though I have run into a little issue. I currently process each image through a loop and sometimes the resize program isn't finished resizing before RunCommand calls the resize program again for the next image and I get an "Error 101: Program Still Running".

Would it be possible to allow multiple instances of the program to be ran so that this issue can't happen?
User avatar
Brian
Developer
Posts: 2678
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: RunCommand 1.0

Post by Brian »

Wallboy wrote:Would it be possible to allow multiple instances of the program to be ran so that this issue can't happen?
Not with the same measure. Have you tried using a secondary RunCommand measure? This would be the only way to run multiple instances of the same program at the same time.

You may have to use the "FinishAction" option to tell your loop that it is done processing and can continue to the next image.

-Brian
Wallboy
Posts: 70
Joined: October 1st, 2012, 4:53 am

Re: RunCommand 1.0

Post by Wallboy »

Doh! I didn't even realize RunCommand had a FinishAction. That is exactly what I needed to avoid this problem. It's working great now. Thanks!
Wallboy
Posts: 70
Joined: October 1st, 2012, 4:53 am

Re: RunCommand 1.0

Post by Wallboy »

I'm guessing this plugin ignores Disabled=1 from what I can tell? Usually I try to set up all my measures to run on demand with EnableMeasure/UpdateMeasure/CommandMeasure Run and then have a FinishAction to DisableMeasure. Guess the enable/disable is not needed for this plugin?
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: RunCommand 1.0

Post by jsmorley »

Wallboy wrote:I'm guessing this plugin ignores Disabled=1 from what I can tell? Usually I try to set up all my measures to run on demand with EnableMeasure/UpdateMeasure/CommandMeasure Run and then have a FinishAction to DisableMeasure. Guess the enable/disable is not needed for this plugin?
This plugin doesn't do any at all unless you tell it to with a !CommandMeasure.
Wallboy
Posts: 70
Joined: October 1st, 2012, 4:53 am

Re: RunCommand 1.0

Post by Wallboy »

Alright that's what I thought, thanks.
User avatar
WandersFar
Posts: 46
Joined: January 25th, 2010, 3:38 pm

Re: RunCommand 1.0

Post by WandersFar »

Could you tell me what I’m doing wrong, please?

I just want to run this little program, RedShift.exe, every fifteen minutes. One of the command line parameters I specify, -o, will run it as a “one-shot,” that is, it will execute the command and then self-terminate, so there should be no need to Close or Kill the program after it’s finished running.

I was using the following code prior to discovering this plugin and it worked as intended. The only thing is it would pop up the ugly cmd window each time, and I read that this plugin can run an exe while hiding the cmd window, which is my goal. So, the original, working code:

[MeasureSwitch]
Measure=Calc
{Irrelevant formula and AboveValue, BelowValue Bangs}
UpdateDivider=900
OnUpdateAction=redshift.exe -o -m wingdi -t 6500:4500 -l 41:-73

I’ve replaced that code with the following:

[MeasureRedShift]
Measure=Plugin
Plugin=RunCommand
Program="#PROGRAMPATH#\RedShift.exe"
Parameter="-o -m wingdi -t 6500:4500 -l 41:-73"

[MeasureSwitch]
Measure=Calc
{Irrelevant formula and AboveValue, BelowValue Bangs}
UpdateDivider=900
OnUpdateAction=!CommandMeasure MeasureRedShift Run

I downloaded the 32-bit version of the plugin and dropped it into this folder of my portable installation of Rainmeter:

Rainmeter\Plugins\RunCommand.dll

So where did I screw up?

Thanks in advance for any help.
Last edited by WandersFar on October 13th, 2014, 2:00 am, edited 1 time in total.