xRedPhantom69 wrote: ↑September 20th, 2024, 11:39 am
So i am creating my own desktop "shortcuts" and my issue is that instead of one of the shortcuts executing an .bat file, it just opens a blank cmd.exe
Code: Select all
//The section in the code:
[meterPowerOffClickable]
Meter=Image
W=69
H=69
X=1361
Y=950
LeftMouseUpAction=["#@#\Bat\shutdown.bat"]
RightMouseUpAction=["#@#\Bat\restart.bat"]
Greyscale=1
SolidColor=00000001
z-order=4
//The bat file:
@echo off
shutdown /s /f /t 0
Thanks
Modern versions of Windows are not happy about executing .bat batch files by just double-clicking on them in File Manager. That is in effect what you are doing with your approach in the Left/Right mouse actions. Batch files are designed to be executed "inside" a cmd.exe console window. So what is happening is that the command is starting a console window, but not executing the contents of the batch file(s).
This can be resolved in Rainmeter by using the
RunCommand Plugin. By default, RunCommand will open a cmd.exe window as the "Program", and then execute whatever is set as the "Parameter" inside that window. The option
State=Hide on the RunCommand measure will make the cmd.exe console window "invisible".
Code: Select all
Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[MeasureExecute]
Measure=Plugin
Plugin=RunCommand
State=Hide
[MeterShutdownRestart]
Meter=Image
W=69
H=69
LeftMouseUpAction=[!SetOption MeasureExecute Parameter "#@#\Bat\shutdown.bat"][!CommandMeasure MeasureExecute "Run"]
RightMouseUpAction=[!SetOption MeasureExecute Parameter "#@#\Bat\restart.bat"][!CommandMeasure MeasureExecute "Run"]
SolidColor=255,255,255,255
What this does is use
!SetOption to set the
Parameter value for the RunCommand measure ([MeasureExecute]), then "run" the command.
Note that this will instantly shutdown or restart your computer, and while it's entirely up to you, I'd be tempted to at least make these a
double-click command and not a single-click, to reduce accidentally running them.
To be honest, unless you need them for some other purpose, I'd lose the .bat files entirely, and just execute the shutdown commands directly.
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[MeasureExecute]
Measure=Plugin
Plugin=RunCommand
State=Hide
[MeterShutdownRestart]
Meter=Image
W=69
H=69
LeftMouseDoubleClickAction=[!SetOption MeasureExecute Parameter "shutdown /s /f /t 0"][!CommandMeasure MeasureExecute "Run"]
RightMouseDoubleClickAction=[!SetOption MeasureExecute Parameter "shutdown /r /f /t 0"][!CommandMeasure MeasureExecute "Run"]
SolidColor=255,255,255,255
Here is an example skin I created a while back...
ShutdownSkin_1.0.rmskin
1.jpg
You do not have the required permissions to view the files attached to this post.