It is currently September 21st, 2020, 12:10 pm

Run Rainmeter as a Service

Get help with installing and using Rainmeter.
rafael.pitanga
Posts: 1
Joined: August 10th, 2020, 6:09 pm

Run Rainmeter as a Service

Post by rafael.pitanga »

Hello everybody,

I'd like to know if Rainmeter can run as a service in Windows. I am trying to configure Rainmeter as a screen watermark and needed that Rainmeter runs as a service, using admin logon so the regular users could not be able to close it, or if they do, I am going to use another program that reopens Rainmeter automatically.

I tried to create a service using this command at Powershell, but it did not work when I try to start the service:

Code: Select all

New-Service -Name "Rainmeter" -DisplayName "Rainmeter" -Description "Rainmeter Service" -StartupType Automatic -BinaryPathName "C:\Program Files\Rainmeter\Rainmeter.exe"
I tried to find something related to that subject at the Forum, but did not find.

Thanks!
dvo
Posts: 969
Joined: February 7th, 2016, 6:08 am

Re: Run Rainmeter as a Service

Post by dvo »

rainmeter isn't a service... and always ways to shutdown... :D
User avatar
SilverAzide
Posts: 954
Joined: March 23rd, 2015, 5:26 pm

Re: Run Rainmeter as a Service

Post by SilverAzide »

rafael.pitanga wrote: August 10th, 2020, 6:24 pm I'd like to know if Rainmeter can run as a service in Windows.
No, it cannot. A Windows Service is a special type of executable, which is why you can't start it. Windows services also don't run like a normal user session, so it wouldn't work even if you could start it.
Gadgets Wiki GitHub More Gadgets...
User avatar
Yincognito
Posts: 2565
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Run Rainmeter as a Service

Post by Yincognito »

Yep. Tried the command, it created the service. However, I could not start it, for the reasons I already read and that were stated by SilverAzide. A word of caution though: if you use the posted command and you do not have PowerShell 6.0 on your PC, you might have trouble deleting the service. If so, delete it through WMI.

That being said, I also read one can create a service from "any executable" using some other software, but I'm not sure the created service would be able to start if it doesn't implement the Windows Services API / ServiceMain. I say this because the creation of the service wasn't a problem, but starting the resulting "service" was.

I would also like to advice folks who pose this kind of questions to post a "rollback method" for other users trying what they post. Personally, I can deal with these situations, but other users might have difficulties doing so.

EDIT: The error I got when trying to start the newly created serice (i.e. Error 1053: The service did not respond to the start or control request in a timely fashion) was precisely because it appears that Rainmeter doesn't implement the Windows Services API / ServiceMain, so even another software might not be of much help in such a case.
User avatar
Active Colors
Moderator
Posts: 612
Joined: February 16th, 2012, 3:32 am

Re: Run Rainmeter as a Service

Post by Active Colors »

Well, since it is not possible to run it as a service, how about trying to hide the process itself from the eyes of task manager?
I have read about the ways to do that.
For example here is one of them https://kaimi.io/2012/09/process-hide-tool/
it is by a russian developer but you can use google translate, there are download buttons on the bottom for exe file and source.
What you need is the frost driver, you can find it as well by searching "frost sys driver" or some similar variation and load it into this tool.
dvo
Posts: 969
Joined: February 7th, 2016, 6:08 am

Re: Run Rainmeter as a Service

Post by dvo »

bij hiding you still can't block the option to not alter the skins... :D
User avatar
Yincognito
Posts: 2565
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Run Rainmeter as a Service

Post by Yincognito »

Normally, if Rainmeter worked as expected (yeah, I have some uncomfortable things to say about this scenario, in particular, but I'll abstain), this should work every time:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
BackgroundMode=2
SolidColor=47,47,47,255
OnCloseAction=[!CommandMeasure MeasureRun "Run"]

---Measures---

[MeasureRun]
Measure=Plugin
Plugin=RunCommand
Program="C:\Program Files\Rainmeter\Rainmeter.exe"
Parameter=!LoadLayout "Test"

---Meters---

[MeterTest]
Meter=STRING
X=0
Y=0
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
Text="Test"
This assumes the above code is a "Test\Test.ini" skin in your skins folder and that you also saved the layout (called "Test" as well) with this skin loaded in your layouts folder. What this does is reload the "Test" layout every time the skin or Rainmeter is closed. The thing is, while this works no problem when unloading the skin, it should work every time when exiting Rainmeter, but it doesn't: in my case I must first unload the skin (and let it reload) 3 times and only then it will also reload when exiting Rainmeter from the skin's context menu. Even so, it seems that when exiting Rainmeter from the system tray, the process doesn't reload Rainmeter and the layout containing this skin again - although it should. Maybe it's about the delays involved in running the measure, I don't know.

Why I didn't use ["C:\Program Files\Rainmeter\Rainmeter.exe" !ActivateConfig "Test" "Test.ini"], you may ask? Simple: because they don't work. I thought it was the placement of quotes in the parameters at fault, so I tried various combinations. I don't recommend trying that yourself, as you might unwantedly create some folders in your Rainmeter installation folder, or have an error about writing to the Rainmeter folder, or even have 2 Rainmeters in system tray, LOL. I might be missing something here, but in my attempts I never managed to make this direct bang work when exiting Rainmeter. To make it work when unloading the skin is trivial, so it doesn't count.

Maybe others can get to the bottom of this, because I couldn't - and frnkly I became a bit annoyed by the fact that things that should work don't, i this case. :confused:

Bottom line is, assuming the above code is made to work in every test case scenario, the only thing required would be to protect the .INI file and the layout file, along with Rainmeter itself from unauthorized modification. There would be no need to run Rainmeter as a service at all, as Rainmeter and the skin would reload every time the user attemps to unload it or close Rainmeter.
User avatar
Yincognito
Posts: 2565
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Run Rainmeter as a Service

Post by Yincognito »

Ok, I'll take back some of the things I said, but while I found a way to make the code work in every test case scenario, it still feels it could have been done in a single bang (must have missed something in those attempts):

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
BackgroundMode=2
SolidColor=47,47,47,255
OnCloseAction=["C:\Program Files\Rainmeter\Rainmeter.exe"][!LoadLayout "Test"]

---Meters---

[MeterTest]
Meter=STRING
X=0
Y=0
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
Text="Test"
So, it reloads Rainmeter and the desired layout every time the user attempts to unload either Rainmeter or the skin. If one can configure the Windows adminstrative policies to prevent the modification of the involved files and access to Task Manager or any other application that can kill Rainmeter "from outside", all good.
User avatar
jsmorley
Developer
Posts: 21373
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Run Rainmeter as a Service

Post by jsmorley »

I don't really follow.

This certainly works in a running skin:

LeftMouseUpAction=["C:\Program Files\Rainmeter\Rainmeter.exe" !ActivateConfig "Test" "Test.ini"]

or from a cmd.exe console:

"C:\Program Files\Rainmeter\Rainmeter.exe" !ActivateConfig "@Working" "Test.ini"

or from the Windows Run dialog:

"C:\Program Files\Rainmeter\Rainmeter.exe" !ActivateConfig "@Working" "Test.ini"

It won't work if Rainmeter is not already running. It's not intended to "start" Rainmeter.

Anyway, I'll step back out, since I disagree with the principle here. Rainmeter is envisioned and designed as an application that is under the complete control of the person sitting in front of the computer. There is no reasonable way, nor do we ever intend to support, any way of "locking down" Rainmeter, so it can be distributed by a company to its employees, in a way where each and every individual workstation doesn't have the ability to change anything and everything about the application.
User avatar
Yincognito
Posts: 2565
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Run Rainmeter as a Service

Post by Yincognito »

jsmorley wrote: August 11th, 2020, 12:27 pmIt won't work if Rainmeter is not already running. It's not intended to "start" Rainmeter.
Yeah, I thought it would though. :confused: Especially since the path to Rainmeter was a part of the bang. I guess this was the thing I was missing when trying the above - it makes sense now.
jsmorley wrote: August 11th, 2020, 12:27 pmAnyway, I'll step back out, since I disagree with the principle here. Rainmeter is envisioned and designed as an application that is under the complete control of the person sitting in front of the computer. There is no reasonable way, nor do we ever intend to support, any way of "locking down" Rainmeter, so it can be distributed by a company to its employees, in a way where each and every individual workstation doesn't have the ability to change anything and everything about the application.
I too disagree with it - giving control to the user is key. I was just trying to make the process work, and I didn't know why it didn't.