Quantcast
Channel: Rainmeter Forums
Viewing all articles
Browse latest Browse all 1616

Help: Rainmeter Skins • Re: Sending powershell commands with curly brackets issue

$
0
0
Well, first off, you are going to want to use RunCommand to do this:

Code:

[Rainmeter]Update=1000AccurateText=1DynamicWindowSize=1[MeasureRun]Measure=PluginPlugin=RunCommandProgram=PowerShellParameter=ping -t 8.8.8.8 | ForEach {"{0} - {1}" -f (Get-Date),$_}State=ShowOutputType=ANSI[MeterString]Meter=StringX=0Y=0FontColor=255,255,255,255FontSize=12SolidColor=0,0,0,1Text=TestAntiAlias=1LeftMouseUpAction=[!CommandMeasure MeasureRun "Run"]

Having said that however, that ping command still gives an error:

Code:

Method invocation failed because [System.Management.Automation.ScriptBlock] does not contain a method named 'op_Subtraction'.At line:1 char:28+ ping -t 8.8.8.8 | ForEach {{0} - {1} -f (Get-Date),$_}+                            ~~~~~~~~~~~~~~~~~~~~~~~~~~    + CategoryInfo          : InvalidOperation: (op_Subtraction:String) [], RuntimeException    + FullyQualifiedErrorId : MethodNotFound
When executed by the plugin. I suspect it has to do with the foreeach{} array command. The other issue you are going to run into is that your command is never-ending, which is going to be a problem as well. You simply can't have a never-ending repetitive command executed by a Rainmeter plugin. The "value" is not returned until the external command "finishes", which this never does. Not quite sure how to correct this.

This simplified version does work, so I suspect there is a solution, I'm just not good enough as Powershell to help much...

Code:

[MeasureRun]Measure=PluginPlugin=RunCommandProgram=PowerShellParameter=ping -t 8.8.8.8 -n 1State=HideOutputType=ANSI
Returns:

Code:

Pinging 8.8.8.8 with 32 bytes of data:Reply from 8.8.8.8: bytes=32 time=12ms TTL=59Ping statistics for 8.8.8.8:    Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),Approximate round trip times in milli-seconds:    Minimum = 12ms, Maximum = 12ms, Average = 12ms

Statistics: Posted by jsmorley — 23 minutes ago



Viewing all articles
Browse latest Browse all 1616

Trending Articles