It is currently May 2nd, 2024, 2:21 am

Power commands (shutdown, restart, etc.) not working?

Get help with creating, editing & fixing problems with skins
User avatar
Falconer
Posts: 115
Joined: August 12th, 2009, 4:10 pm
Location: Behind you!

Power commands (shutdown, restart, etc.) not working?

Post by Falconer »

Hello everyone,
Today I decided to try my hand at using the Button meter. My idea was to do a power control skin using the commands from this Tips and Tricks article. I know I'm doing the button meter and the !bang format right, because if I try to use other commands like the ones for the Control Panel or Task Manager in the skin, it works. Also, running the commands given in the Tips and Tricks article in the Windows "Run" dialogue also works. But launching those same commands from the skin does not seem to work at all, and I'm totally stumped.
:confused:
I'm using Win7 64-bit on a Standard account, so I tried running Rainmeter as my Administrator account - no difference.
Did I miss some fine print somewhere? (i.e. "Note that the Button meter does not work with certain system commands.")

My code:

Code: Select all

[Rainmeter]
Author=Colonel Darby | droid.delusional@gmail.com
Update=1000
AppVersion=1003000

[Metadata]

[Variables]

[ToggleMeter]
Meter=BUTTON
X=5
Y=5
ButtonImage=#ROOTCONFIGPATH#\Images\ShutdownButton.png
ButtonCommand=!RainmeterToggleMeterGroup Power

[ShutdownMeter]
Meter=BUTTON 
X=r
Y=5R
ButtonImage=#ROOTCONFIGPATH#\Images\ShutdownButton.png
ButtonCommand=!Execute ["shutdown.exe -s"]
Group=Power

[RestartMeter]
Meter=BUTTON 
X=5R
Y=r
ButtonImage=#ROOTCONFIGPATH#\Images\RestartButton.png
ButtonCommand=!Execute ["shutdown.exe -r"]
Group=Power

[HbernateMeter]
Meter=BUTTON 
X=5R
Y=r
ButtonImage=#ROOTCONFIGPATH#\Images\HibernateButton.png
ButtonCommand=!Execute ["rundll32.exe powrprof.dll,SetSuspendState"]
Group=Power

[SleepMeter]
Meter=BUTTON 
X=5R
Y=r
ButtonImage=#ROOTCONFIGPATH#\Images\SleepButton.png
ButtonCommand=!Execute ["Rundll32.exe Powrprof.dll,SetSuspendState Sleep"]
Group=Power

[LogoutMeter]
Meter=BUTTON 
X=5R
Y=r
ButtonImage=#ROOTCONFIGPATH#\Images\LogoutButton.png
ButtonCommand=!Execute ["shutdown.exe -l"]
Group=Power

[LockMeter]
Meter=BUTTON 
X=5R
Y=r
ButtonImage=#ROOTCONFIGPATH#\Images\LockButton.png
ButtonCommand=!Execute ["rundll32.exe user32.dll LockWorkStation"]
Group=Power
Thanks for your time,
Darby/Falconer/DelusionalDroid/et al
Last edited by Falconer on January 3rd, 2011, 11:51 pm, edited 1 time in total.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Power commands (shutdown, restart, etc.) not working?

Post by jsmorley »

It's a quotes issue. When executing commands from a bang, you generally want to put the .exe and its parms in separate quotes. I'm not going to play with your specific example, as I don't feel like rebooting over and over :-)

But play with quotes and spaces and you will get it.
User avatar
Falconer
Posts: 115
Joined: August 12th, 2009, 4:10 pm
Location: Behind you!

Re: Power commands (shutdown, restart, etc.) not working?

Post by Falconer »

Thanks jsmorley!

Yeah, it's a bit of a pain to test. :) I changed the logout command to ["shutdown.exe" "-l"] and that works, so I think restart and shutdown should work as well since they are the same command, just different parameters. I'll have to play around with hibernate, sleep, and lock some more since they are more complicated... any advice on how to format "rundll32.exe powrprof.dll setsuspendstate sleep" ?
dragonmage
Developer
Posts: 1270
Joined: April 3rd, 2009, 4:31 am
Location: NC, US

Re: Power commands (shutdown, restart, etc.) not working?

Post by dragonmage »

I'd try this first

"rundll32.exe" powrprof.dll setsuspendstate sleep

then

"rundll32.exe" "powrprof.dll" setsuspendstate sleep

etc.