It is currently March 28th, 2024, 7:14 pm

OPEN and CLOSE HWINFO

Get help with installing and using Rainmeter.
PHILleHUt
Posts: 17
Joined: April 8th, 2020, 2:35 pm
Location: PARIS - FRANCE

OPEN and CLOSE HWINFO

Post by PHILleHUt »

Hi all,

I'm doing my own skin and rainmeter is always quite new for me. So I will need some help again.
First, I creat an On/Off buton which open some .exe and .ini files.

Openig is quite simple:

LeftMouseUpAction=[!ShowMeter MeterCloseBoutonAllume] [!HideMeter MeterCloseFondBoutonEtteint] [!ShowMeter MeterFondBoutonAllume][!HideMeter MeterFondBoutonEtteint][!Update] [!ToggleConfig "PHILleHUt\HORLOGE" "horloge.ini"] [!ToggleConfig "PHILleHUt\parametresC" "parametres.ini"] [!ToggleConfig "PHILleHUt\pc" "pc.ini"] ["C:\Users\PHILleHUt\Documents\Rainmeter\Skins\PHILleHut\HWINFO64.exe" ]



But I can't close the .exe files (here HWINFO064.exe)
Can someone help me?
:great: Thanks for All :great:
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: OPEN and CLOSE HWINFO

Post by jsmorley »

You can't easily do this in my view.

The trouble is that HWiNFO requires administrator privileges to run and requires administrator privileges to be killed with something like taskkill.exe. There is no way using a call to taskkill.exe either directly or with the RunCommand plugin to gain that level of access. That would be a huge security risk.

You could write something in AutoIt or presumably nircmd that could request administrator level before executing, but assuming that you have UAC turned on, and you are a knucklehead of you don't, it's going to pop up a dialog asking for confirmation / permission to do so.

I don't think HWiNFO is a good candidate for this kind of control. It's just too intimate with your hardware to be that unsecured.

There is a reason why the icon for HWiNFO64.exe has the little "shield" on it...


1.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: OPEN and CLOSE HWINFO

Post by jsmorley »

In AutoIt, it's two simple lines:

Code: Select all

#RequireAdmin
ProcessClose("HWiNFO64.EXE")
KillHWiNFO.zip

However as I said, with the #RequireAdmin directive it works, but will pop up a UAC prompt. Without the directive, it won't work at all.

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]

[MeterHWiNFO]
Meter=String
FontSize=20
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=Close HWiNFO
LeftMouseUpAction=["#@#KillHWiNFO.exe"]
You do not have the required permissions to view the files attached to this post.
PHILleHUt
Posts: 17
Joined: April 8th, 2020, 2:35 pm
Location: PARIS - FRANCE

Re: OPEN and CLOSE HWINFO

Post by PHILleHUt »

Ok ok now i understand why i haven't found any solution in this forum before.....

Well, I used ["#@#KillHWiNFO.exe"].

But it doesn't stop HWINFO :-(
Last edited by PHILleHUt on April 11th, 2020, 5:53 pm, edited 1 time in total.
:great: Thanks for All :great:
PHILleHUt
Posts: 17
Joined: April 8th, 2020, 2:35 pm
Location: PARIS - FRANCE

Re: OPEN and CLOSE HWINFO

Post by PHILleHUt »

Well, I found a solution:

1- no change to open HWINFO

2-to close HWINFO, I just put the same instruction: ["C: \ Users \ augus \ Documents \ Rainmeter \ Skins \ PHILleHut \ HWINFO64.exe"]

HWINFO restarts. The main window and the sensor window appear even if I chose to hide them in the HWINFO settings.
I now click on the main window's cross to close HWINFO.


QUITE STRANGE BUT... I am almost satisfied
:great: Thanks for All :great:
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: OPEN and CLOSE HWINFO

Post by balala »

SORRY THIS DOESN'T WORK THIS WAY. Described here why.
Sorry for the inconvenience.

Beside jsmorley's definitely good solution, there is a somehow simple (or simpler) solution in my opinion, which doesn't require AutoIt. You have to use a Process plugin measure to check if HWINFO64 is running and close it if it is or launch it if it's not.
If you wanna give it a try, add the following two measures to your code:

Code: Select all

[MeasureCloseHWiNfo64]
Measure=Plugin
Plugin=RunCommand
Parameter=taskkill /im HWINFO64.exe
State=Hide
OutputType=ANSI

[MeasureHWINFO64]
Measure=Plugin
Plugin=Process
ProcessName=HWINFO64.exe
IfCondition=(#CURRENTSECTION#>0)
IfTrueAction=[!SetVariable Action """[!CommandMeasure "MeasureCloseHWiNfo64" "Run"]"""][!UpdateMeter "MeterAction"]
IfFalseAction=[!SetVariable Action """["C:\Users\PHILleHUt\Documents\Rainmeter\Skins\PHILleHut\HWINFO64.exe" ]"""][!UpdateMeter "MeterAction"]
[MeasureHWINFO64] checks if the HWINFO64 process is running and it sets a variable (I named it Action) to different values, when the process is running or not. The [!UpdateMeter "MeterAction"] bang updates the meter which has the posted and below modified LeftMouseUpAction option set. Probably you have used another name for it, so for sure you have to modify its name into the above code, but hope you got the idea.
Now you have to modify the above LeftMouseUpAction option as it follows: LeftMouseUpAction=[!ShowMeter "MeterCloseBoutonAllume"][!HideMeter "MeterCloseFondBoutonEtteint"][!ShowMeter "MeterFondBoutonAllume"][!HideMeter "MeterFondBoutonEtteint"][!Redraw][!ToggleConfig "PHILleHUt\HORLOGE" "horloge.ini"][!ToggleConfig "PHILleHUt\parametresC" "parametres.ini"][!ToggleConfig "PHILleHUt\pc" "pc.ini"]#Action#. Make sure to add a DynamicVariables=1 option to the meter having the above LeftMouseUpAction set (if it's not already), because this option having a dynamically set variable (Action), requires to set this option.
Also note that in the above LeftMouseUpAction option I:
  • Added somequotations around the meter names used into the !HideMeter / !ShowMeter bangs, which always seems a good idea.
  • Changed the [!Update] bang with [!Redraw], because when you hide / show meters, there is not needed to update the whole skin, redrawing it is completely enough.
  • Removed the spaces between the consecutive bangs (also not needed, but might be very confusing in some circumstances).
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: OPEN and CLOSE HWINFO

Post by jsmorley »

PHILleHUt wrote: April 11th, 2020, 5:37 pm Ok ok now i understand why i haven't found any solution in this forum before.....

Well, I used ["#@#KillHWiNFO.exe"].

But it doesn't stop HWINFO :-(
Be sure you download KillHWiNFO.exe from my post above, and put it in the @Resources folder of your skin.

https://docs.rainmeter.net/manual/skins/resources-folder/
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: OPEN and CLOSE HWINFO

Post by jsmorley »

balala wrote: April 11th, 2020, 5:56 pm Beside jsmorley's definitely good solution, there is a somehow simple (or simpler) solution in my opinion, which doesn't require AutoIt. You have to use a Process plugin measure to check if HWINFO64 is running and close it if it is or launch it if it's not.
If you wanna give it a try, add the following two measures to your code:

Code: Select all

[MeasureCloseHWiNfo64]
Measure=Plugin
Plugin=RunCommand
Parameter=taskkill /im HWINFO64.exe
State=Hide
OutputType=ANSI

[MeasureHWINFO64]
Measure=Plugin
Plugin=Process
ProcessName=HWINFO64.exe
IfCondition=(#CURRENTSECTION#>0)
IfTrueAction=[!SetVariable Action """[!CommandMeasure "MeasureCloseHWiNfo64" "Run"]"""][!UpdateMeter "MeterAction"]
IfFalseAction=[!SetVariable Action """["C:\Users\PHILleHUt\Documents\Rainmeter\Skins\PHILleHut\HWINFO64.exe" ]"""][!UpdateMeter "MeterAction"]
Sorry, but as I said before, this just won't work... RunCommand will not execute taskkill.exe as an "Administrator", and so will not be able to kill the HWiNFO64.exe process.


1.jpg

The only way to overcome that would be to either run Rainmeter.exe itself "As Administrator" when you start it, or turn off UAC in Windows. Both of those approaches are entirely unacceptable to me. Defeating the security built into Windows is just a horrible idea. Running Rainmeter as an administrator is just dangerous and careless. Either are probably ok if you really know what you are doing and are very careful about what you do and what skins you install, but my starting position is that nobody except me has any idea of what they are doing, and I often wonder about myself.
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: OPEN and CLOSE HWINFO

Post by balala »

jsmorley wrote: April 11th, 2020, 6:20 pm Sorry, but as I said before, this just won't work...
Well, I have not installed HWiNFO64, so can't check but tried with other installed programs (Notepad, Total Commander, Notepad++. Microsoft Word and so on) and worked with each of them. Is HWiNFO64 anyway different?
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: OPEN and CLOSE HWINFO

Post by jsmorley »

balala wrote: April 11th, 2020, 7:07 pm Well, I have not installed HWiNFO64, so can't check but tried with other installed programs (Notepad, Total Commander, Notepad++. Microsoft Word and so on) and worked with each of them. Is HWiNFO64 anyway different?
Yes. It is a program that must be run "As Administrator", and thus can only be killed "As Administrator".

taskkill.exe is not a Windows application, and has no ability to ask for administrator privileges itself. Whatever command environment it is run in must be run "As Administrator" or have the ability to request an escalation from Windows. The RunCommand plugin does not have this ability, and so any call to taskkill.exe that tries to kill a "protected" application will simply fail.

The AutoIt program I wrote does have the ability to request escalation from Windows, and although this will cause a UAC prompt requesting confirmation from you, it will work.