Page 3 of 4
Re: Can I close an application with Rainmeter?
Posted: July 31st, 2021, 1:00 pm
by sl23
Sorry, one more thing...
What do these mean: /IM /T /F I can;'t seem to find any info about them. I've done a web search but the several pages I looked at for powershell commands don't show these.
I see the last two have been omitted in your code, I suppose /F is to force the app to close? Is /T for setting a time?
Re: Can I close an application with Rainmeter?
Posted: July 31st, 2021, 1:05 pm
by jsmorley
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.
Re: Can I close an application with Rainmeter?
Posted: July 31st, 2021, 1:06 pm
by jsmorley
sl23 wrote: ↑July 31st, 2021, 1:00 pm
Sorry, one more thing...
What do these mean:
/IM /T /F I can;'t seem to find any info about them. I've done a web search but the several pages I looked at for powershell commands don't show these.
I see the last two have been omitted in your code, I suppose
/F is to force the app to close? Is
/T for setting a time?
Those are parameters for the built-in taskkill.exe in Windows...
Code: Select all
PS C:\Users\JSMorley> taskkill /?
TASKKILL [/S system [/U username [/P [password]]]]
{ [/FI filter] [/PID processid | /IM imagename] } [/T] [/F]
Description:
This tool is used to terminate tasks by process id (PID) or image name.
Parameter List:
/S system Specifies the remote system to connect to.
/U [domain\]user Specifies the user context under which the
command should execute.
/P [password] Specifies the password for the given user
context. Prompts for input if omitted.
/FI filter Applies a filter to select a set of tasks.
Allows "*" to be used. ex. imagename eq acme*
/PID processid Specifies the PID of the process to be terminated.
Use TaskList to get the PID.
/IM imagename Specifies the image name of the process
to be terminated. Wildcard '*' can be used
to specify all tasks or image names.
/T Terminates the specified process and any
child processes which were started by it.
/F Specifies to forcefully terminate the process(es).
/? Displays this help message.
Filters:
Filter Name Valid Operators Valid Value(s)
----------- --------------- -------------------------
STATUS eq, ne RUNNING |
NOT RESPONDING | UNKNOWN
IMAGENAME eq, ne Image name
PID eq, ne, gt, lt, ge, le PID value
SESSION eq, ne, gt, lt, ge, le Session number.
CPUTIME eq, ne, gt, lt, ge, le CPU time in the format
of hh:mm:ss.
hh - hours,
mm - minutes, ss - seconds
MEMUSAGE eq, ne, gt, lt, ge, le Memory usage in KB
USERNAME eq, ne User name in [domain\]user
format
MODULES eq, ne DLL name
SERVICES eq, ne Service name
WINDOWTITLE eq, ne Window title
NOTE
----
1) Wildcard '*' for /IM switch is accepted only when a filter is applied.
2) Termination of remote processes will always be done forcefully (/F).
3) "WINDOWTITLE" and "STATUS" filters are not considered when a remote
machine is specified.
Examples:
TASKKILL /IM notepad.exe
TASKKILL /PID 1230 /PID 1241 /PID 1253 /T
TASKKILL /F /IM cmd.exe /T
TASKKILL /F /FI "PID ge 1000" /FI "WINDOWTITLE ne untitle*"
TASKKILL /F /FI "USERNAME eq NT AUTHORITY\SYSTEM" /IM notepad.exe
TASKKILL /S system /U domain\username /FI "USERNAME ne NT*" /IM *
TASKKILL /S system /U username /P password /FI "IMAGENAME eq note*"
Re: Can I close an application with Rainmeter?
Posted: July 31st, 2021, 1:11 pm
by sl23
Ah ok thanks for the tip on elevated tasks
Re: Can I close an application with Rainmeter?
Posted: July 31st, 2021, 1:14 pm
by jsmorley
sl23 wrote: ↑July 31st, 2021, 1:11 pm
Ah ok thanks for the tip on elevated tasks
Sure. I'd be hesitant to distribute a skin that required an "elevated" command to Powershell though. The issue is that running it will cause UAC (User Account Control) to pop up a confirmation dialog, and that might be somewhat disconcerting to your users.
Re: Can I close an application with Rainmeter?
Posted: July 31st, 2021, 1:27 pm
by Active Colors
sl23 wrote: ↑July 31st, 2021, 10:22 am
I don't suppose Rainmeter has been updated to support this?
EDIT: I found out how to do this via .bat file. But would be a good to know if Rm has had this function added or not.
I know you added the edit but for anyone else who wants the addon here it is attached.
Runs simply:
Code: Select all
LeftMouseUpAction=["#@#TaskKiller.exe" "notepad.exe"]
635 kb executable.
Source inside as well.
Made in AutoIt.
Courtesy of moshi.
Re: Can I close an application with Rainmeter?
Posted: July 31st, 2021, 1:28 pm
by sl23
I'll keep that in mind, but I probably won't share any skins after the last time!
Re: Can I close an application with Rainmeter?
Posted: July 31st, 2021, 1:34 pm
by jsmorley
Active Colors wrote: ↑July 31st, 2021, 1:27 pm
I know you added the edit but for anyone else who wants the addon here it is attached.
Runs simply:
Code: Select all
LeftMouseUpAction=["#@#TaskKiller.exe" "notepad.exe"]
635 kb executable.
Source inside as well.
Made in AutoIt.
Courtesy of moshi.
I just don't see any advantage to an external application, written in AutoIt that many antivirus apps hate, to replace something that is just built-into Windows. Likely Moshi wrote this before we had the RunCommand plugin I guess, in order to suppress the display of a command window for a second. I'd vote against this in the current environment.
Re: Can I close an application with Rainmeter?
Posted: July 31st, 2021, 1:42 pm
by jsmorley
sl23 wrote: ↑July 31st, 2021, 1:28 pm
I'll keep that in mind, but I probably won't share any skins after the last time!
I would not let anything that happened before discourage you. Feel free to distribute skins as you like. Just give appropriate credit to authors your work uses or is directly based on, and all will be well. You might run into a jerk from time to time who doesn't get that Rainmeter is ALL ABOUT sharing and learning by using other's code, but that's their karma, not yours.
Re: Can I close an application with Rainmeter?
Posted: July 31st, 2021, 1:54 pm
by sl23
Ok thank you
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!