Power profile for clients with no logged on user

(imported topic written by MattBoyd)

On a subset of machines, we want to prevent the system from going into standby whenever a user is logged on. When there is no user logged on, we would like the machine to enter standby after 45 minutes. To do this, I was planning to deploy two power profiles using the power profile wizard that are applicable depending on whether or not a user is logged on.

For the power profile that runs when no user is logged on, I followed the instructions here: http://forum.bigfix.com/viewtopic.php?id=2337. I removed the “exists current user” relevance but the fixlet is still not applicable on machines with no user logged on.

Can anyone help me get a power profile fixlet working on machines with no logged on user?

Thanks

(imported comment written by BenKus)

Hey Boyd,

Windows XP power profiles are weird… Every time any user logs in, the power profile of the computer is set to the last person that logs in and it stays there (even after the user logs out). So if you set this setting when no user is logged in, it will just get reset after the next user logs in…

You might do better creating an action that runs when no users are logged in that forces standby… The tricky part would be adding the 45 min timer… I suppose you can add it to the actionscript and then doublecheck after 45 min that the user is still idle, but it isn’t exactly pretty…

Ben

(imported comment written by SystemAdmin)

Boyd,

We need to do the same thing. Conference Room computers and other systems being used for presentations. Please share whatever you come up with. Thx.

John

(imported comment written by MattBoyd)

Ben/John,

I took a shot of courage (Smirnoff and gingerale) last night and sifted through the mind-numbing relevance that’s generated by the Power Profile Wizard. I discovered that the relevance that inspects user registry keys was causing the problem. For the power profile that runs when no user is logged on, this is the relevance I ripped out (yours will vary slightly):

( ( 

if name of operating system = 
"Mac OS X" then 
"Custom" 

else 
"CLM Podiums User (x-x-x)" ) as lowercase != it as lowercase ) of ( 

if name of operating system = 
"Mac OS X" then ( 

if exists file 
"/Library/Preferences/SystemConfiguration/com.apple.PowerManagement.plist" then ( ( 

if it = 3 then 
"Better Performance" 

else ( 

if it = 2 then 
"Normal" 

else ( 

if it = 1 then 
"Better Energy Savings" 

else 
"Custom" ) ) ) of integer 
"AC Power" of dictionary 
"ActivePowerProfiles" of dictionary of it ) of file 
"/Library/Preferences/SystemConfiguration/com.apple.PowerManagement.plist" 

else 
"Normal" ) 

else ( 

if ( name of operating system = 
"WinVista" ) then ( 

if ( value 
"FriendlyName" of key ( 
"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\" &  ( value 
"ActivePowerScheme" of key 
"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\" of registry as string ) ) of registry as string ) contains 
"," then ( following text of last 
"," of preceding text of first 
"%00" of ( value 
"FriendlyName" of key ( 
"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\" &  ( value 
"ActivePowerScheme" of key 
"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\" of registry as string ) ) of registry as string ) ) 

else ( preceding text of first 
"%00" of ( value 
"FriendlyName" of key ( 
"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\" &  ( value 
"ActivePowerScheme" of key 
"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\" of registry as string ) ) of registry as string ) ) ) 

else ( ( value 
"name" of key ( 
"Control Panel\PowerCfg\PowerPolicies\" & value "CurrentPowerPolicy
" of key "Control Panel\PowerCfg
" of it as string ) of it as string ) of ( key ( 
"HKEY_USERS\" &  ( name of key whose ( name of it as lowercase != 
".default" AND name of it as lowercase != 
"s-1-5-18" AND name of it as lowercase != 
"s-1-5-19" AND name of it as lowercase != 
"s-1-5-20" AND value 
"Logon User Name" of key 
"Software\Microsoft\Windows\CurrentVersion\Explorer" of it as string as lowercase = ( 

if exists first 
"\" of  ( value 
"Logon User Name" of key 
"Software\Microsoft\Windows\CurrentVersion\Explorer" of it as string ) then ( preceding text of first 
"\" of  ( value 
"Logon User Name" of key 
"Software\Microsoft\Windows\CurrentVersion\Explorer" of it as string as lowercase ) & 
"\" & name of current user as string as lowercase ) 

else ( name of current user as string as lowercase ) ) ) of key 
"HKEY_USERS" of registry ) ) of registry ) ) ) ) OR

I also changed “exists current user” to “not exists current user” to prevent the profile from being applied when a user is logged on. I haven’t tested this thoroughly, but it seems to work. Remember, you still need to remove the “RunAsCurrentUser” portions of the action script. I’ve attached the fixlet that I’m using so you can compare and contrast. You’ll probably want to make your own though.

As a side note, I discovered that if there are two spaces between “waithidden” and a command in actionscript, it will fail:

Command failed (Thread execution failed) waithidden  
"C:\WINDOWS\system32\powercfg.exe" /create 
"CLM Podiums No User (15-20-45)"

Make sure that any extra spaces are removed when you get rid of the “RunAsCurrentUser” portion of the commands.

(imported comment written by BenKus)

Hi boyd,

I am not sure this will work in all cases… after having dealt with Windows power policy reg keys and strange behaviors for a few years now, I can tell you that it is quite tricky and things do not always work like you would expect.

The first issue I think you will hit is that whenever a user logs in the computer, it will overwrite the power policies (HKLM and HKCU).

Ben

(imported comment written by MattBoyd)

Hey Ben,

I agree with you, Windows Power Management is quite mysterious… especially in XP. They did make some significant improvements in Windows 7. For example, you can actually run a powercfg command to see what processes are preventing the machine from going to sleep.

I’m not positive that all of this will work consistently, so I’ve set the standby timeouts relatively high (240 minutes when someone is logged in, 45 minutes when they aren’t). For this subset of machines, I’m more concerned about them going to sleep mid-lecture than putting them to sleep consistently. If the “no user” power settings don’t always work, I’m not going to lose sleep over it (pun intended).

Regarding the user log ons overwriting power policies, I have applied a regular power profile (via the power profile wizard) that should reapply the settings whenever a user is logged on, so I actually have two power policies applied to these machines through BigFix. Fingers crossed, I’m hoping this will work.

The machines I am testing this on seem to be consistently applying their power settings based on whether or not a user is logged on. They’re sleeping right now (6am), which is good.