It is currently April 25th, 2024, 7:25 am

Why does this ini crash Rainmeter on startup?

Get help with creating, editing & fixing problems with skins
User avatar
Cariboudjan
Posts: 268
Joined: May 12th, 2019, 8:55 am

Why does this ini crash Rainmeter on startup?

Post by Cariboudjan »

The below is an excerpt from another skin. I identified it as the cause of a crash loop. I have no idea why it causes a crash. It seems to affect slower machines more than others. If it does not cause a crash immediately on load, try looking at it its values in the About pane. For some reason viewing its values in the About pane triggers a crash if it doesn't crash on startup.

The RunCommand does not need to be run. The measure just needs to exist in the ini to cause a crash loop.

Code: Select all

[Variables]
LastFocusedIM=Rainmeter.exe

[Meter]
Meter=String

[RunGetPath]
Measure=Plugin
Plugin=RunCommand
Parameter=wmic process where "name='#LastFocusedIM#'" get ProcessID, ExecutablePath /FORMAT:LIST
State=Hide
OutputType=ANSI
OutputFile=
RegExpSubstitute=1
Substitute="(\r?\n|\r)":"","ExecutablePath=(.*)":"\1","(?<=exe)(?s)(.*$)":"","([^\\]*$)":""
DynamicVariables=1
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Why does this ini crash Rainmeter on startup?

Post by balala »

Cariboudjan wrote: December 3rd, 2020, 4:31 pm I have no idea why it causes a crash.
Due to the substitution, specifically to the last ("([^\\]*$)":"") substitution.
To be honest I can!t realiye what zour intention with that substitution was, so not sure how to fix it. What did you want to do?
User avatar
Cariboudjan
Posts: 268
Joined: May 12th, 2019, 8:55 am

Re: Why does this ini crash Rainmeter on startup?

Post by Cariboudjan »

Remove everything after the initial line, including line breaks, since the command line gives multiple results.
Last edited by Cariboudjan on December 3rd, 2020, 6:09 pm, edited 1 time in total.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Why does this ini crash Rainmeter on startup?

Post by jsmorley »

https://docs.rainmeter.net/manual/measures/general-options/substitute/
Note: With RegExpSubstitute, a (capture) may not return an empty string. Care should be taken when using * (zero or more) quantifiers or (?(?= (If/Then) lookahead tests, as a capture must either cause the entire regular expression to "fail", or return a value of some kind.
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Why does this ini crash Rainmeter on startup?

Post by balala »

Cariboudjan wrote: December 3rd, 2020, 6:02 pm Remove everything after the initial line, including line breaks, since the command line gives multiple results.
What about this substitution: Substitute="ExecutablePath=(.*)\n.*":"\1","\n":""?
User avatar
Cariboudjan
Posts: 268
Joined: May 12th, 2019, 8:55 am

Re: Why does this ini crash Rainmeter on startup?

Post by Cariboudjan »

I'll try it. Thanks.
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Why does this ini crash Rainmeter on startup?

Post by balala »

Cariboudjan wrote: December 3rd, 2020, 6:29 pm I'll try it. Thanks.
Ok. Let me know how does it work.
User avatar
Cariboudjan
Posts: 268
Joined: May 12th, 2019, 8:55 am

Re: Why does this ini crash Rainmeter on startup?

Post by Cariboudjan »

Doesn't work. Returns this for msedge.exe

C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exeC:\Program Files (x86)\Microsoft\Edge\Application\msedge.exeC:\Program Files (x86)\Microsoft\Edge\Application\msedge.exeC:\Program Files (x86)\Microsoft\Edge\Application\msedge.exeC:\Program Files (x86)\Microsoft\Edge\Application\msedge.exeC:\Program Files (x86)\Microsoft\Edge\Application\msedge.exeC:\Program Files (x86)\Microsoft\Edge\Application\msedge.exeC:\Program Files (x86)\Microsoft\Edge\Application\msedge.exeC:\Program Files (x86)\Microsoft\Edge\Application\msedge.exeC:\Program Files (x86)\Microsoft\Edge\Application\msedge.exeC:\Program Files (x86)\Microsoft\Edge\Application\msedge.exeC:\Program Files (x86)\Microsoft\Edge\Application\msedge.exeC:\Program Files (x86)\Microsoft\Edge\Application\msedge.exeC:\Program Files (x86)\Microsoft\Edge\Application\msedge.exeC:\Program Files (x86)\Microsoft\Edge\Application\msedge.exeC:\Program Files (x86)\Microsoft\Edge\Application\msedge.exeC:\Program Files (x86)\Microsoft\Edge\Application\msedge.exeC:\Program Files (x86)\Microsoft\Edge\Application\msedge.exeC:\Program Files (x86)\Microsoft\Edge\Application\msedge.exeC:\Program Files (x86)\Microsoft\Edge\Application\msedge.exeC:\Program Files (x86)\Microsoft\Edge\Application\msedge.exeC:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe

But adding "(?<=exe)(?s)(.*$)":"" worked to remove everything after the first .exe.

And yeah, "([^\\]*$)":"" was to remove everything after the last backslash. So I can get the folder location of the application (eg. turn C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe into C:\Program Files (x86)\Microsoft\Edge\Application\)
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Why does this ini crash Rainmeter on startup?

Post by balala »

Cariboudjan wrote: December 3rd, 2020, 7:10 pm Doesn't work. Returns this for msedge.exe
I'm surprised it does return so many strings, because for me it returns only one line, even if I modified the LastFocusedIM variable to LastFocusedIM=msedge.exe (what I guess you mean by "for msedge.exe").
User avatar
Cariboudjan
Posts: 268
Joined: May 12th, 2019, 8:55 am

Re: Why does this ini crash Rainmeter on startup?

Post by Cariboudjan »

It's alright. I modified it. I have it almost going now. I just need to find a way to remove everything after the last backslash without crashing Rainmeter again.

eg. Change C:\Windows\Explorer.exe to C:\Windows\

I used this before, but this crashes Rainmeter for a reason I still don't fully understand. I assume because when the skin first loads, it contains no value, and therefor there is no "\" to find or anything after it. Still though. Why does this crash Rainmeter? Why doesn't it just fail?
Screenshot 2020-12-03 123130.png


Tried changing it to this. It doesn't crash Rainmeter, but it also doesn't do anything in Rainmeter, even though it works in the regex101 test.
Screenshot 2020-12-03 124409.png
You do not have the required permissions to view the files attached to this post.