It is currently April 27th, 2024, 2:18 am

Can I close an application with Rainmeter?

Get help with creating, editing & fixing problems with skins
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Can I close an application with Rainmeter?

Post by jsmorley »

sl23 wrote: July 31st, 2021, 1:54 pm Ok thank you :welcome:

Tbh though, I think about 80% of my code is copied from others! My Media skin started off with Poiru's work on Soita for example. Then my drives code included in my sidebar skin was mostly done by yourself. Even RecycleBin was mostly copied from Illustro then enhanced through requests on here. I'm just not that good at this coding thing, much as I'd like to be.

The only reason I shared in the past was to pass these ideas on to others, NOT to take credit for it, because I simply can't!

Like the CountdownTimer I'm adapting from Balala's skin, it's his work, even if I am changing it a great deal to suit my way of working and condensing parts, the issues I'm having are just beyond me! But I do try to have a go myself before asking for help as it is quite good fun really, even if a little frustrating at times! :lol:
Rainmeter is a lot of fun. DO ask for help anytime you need it, we are glad to help out when we can.
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Can I close an application with Rainmeter?

Post by sl23 »

It is indeed! And I'm quite amazed sometimes how good a community you have here! Most forums are ok, but thanks to the likes of yourself, balala, Yincognito, death crafter, eclectic tech, and many more who have hepled me and so many others by taking time to read comments, write code and provide sooo much help, without which many like myself would be stuck!

So thanks to all those great bods and sorry if I didn't mention anyone whose greatness should also be known! :D :D :D
- MuLab -
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Can I close an application with Rainmeter?

Post by Yincognito »

jsmorley wrote: July 31st, 2021, 1:05 pm One thing to keep in mind is that RunCommand will open Powershell with the default security level.

If you need to execute a command that requires being run "As Administrator", it's a bit different.

Code: Select all

[MeasureClose]
Measure=Plugin
Plugin=RunCommand
Program=PowerShell
Parameter=Start-Process -FilePath "taskkill" -ArgumentList "/IM autoruns.exe" -verb RunAs
Since the program autoruns.exe is run with administrator access, killing it also requires administrator access. So you have to "elevate" the command when you run it. That is what the -verb RunAs does.
Quick Note: Running the above (i.e. without the /F taskkill parameter) on Rainmeter.exe where a suite of skins is loaded will result in the interesting behavior of the skins in that suite being killed one by one, sequentially. :???:

Side Question: Just looking for a second opinion on this, but after overcoming the CMD quirks regarding quotes and escaping them and building myself an (apparently, slightly quicker) alternative to my original:

Code: Select all

Program=powershell
Parameter=Start-Process powershell -windowstyle Hidden -verb RunAs \"Stop-Process -Name '#ProcessToKill#' -Force; Exit\"
by changing into:

Code: Select all

Program=powershell
Parameter=Start-Process taskkill -windowstyle Hidden -verb RunAs '/F /FI \"IMAGENAME eq #ProcessToKill#.*\"'
where #ProcessToKill# is a variable holding just the name of the process (i.e. without the .exe or whatever part), do you think there is any difference between the two, regarding how they identify the process without the help of an extension part to make the identification purely literal?
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth