LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I control the computer's power-management state?

I have a Labview application that I have distributed to several test computers in various locations.

 

The laptops have power-management schemes which cause the computer to go to sleep or shut down after a certain period of user inactivity. 

 

When we are collecting data for hours or days at a time, this is a problem.

 

Although I have asked the operators to check that the power manager is set to a mode which will not shut down the computer, I would really like to never worry about this again by having Labview somehow detect or set the power management state.  Can someone recommend a way to do this?

 

Thanks!

 

 

0 Kudos
Message 1 of 5
(3,266 Views)

 

 

Hi,

 

In windows os, go to control panel/ power options and then choose the power schemes tab. Then you can set the scheme to ALWAYS ON from the drop down menu.

 

hosa

Message 2 of 5
(3,256 Views)

@hosa wrote:

 

In windows os, go to control panel/ power options and then choose the power schemes tab. Then you can set the scheme to ALWAYS ON from the drop down menu.


Yep.

 

Also, in Device Manager, USB Controllers, in the "Power Management" tab of all the root hubs, uncheck "Allow the computer to turn off the device to save power".  That's given me a lot of grief in the past.

Message 3 of 5
(3,247 Views)

I think you've misunderstood my question.

 

I would like the PROGRAM to control the power management state, not the USER.

 

Your suggestion is precisely what we already do.  However, the laptop seems to have something else (probably some policy setup by our IT department...) which makes it impossible to ensure that the power management scheme will always be set to the one we want.

 

How do I do this programmatically?

0 Kudos
Message 4 of 5
(3,246 Views)

Controlling it may depend upon security. I would suggest that you query the status and then indicate to the user/operator that the settings need to be changed.

 

You can look in this example I posted years ago for a way to get and monitor the Windows kernel SystemPowerStatus.

 

The example goes a step further and registers to receive events if the power state changes. If your laptop lost external power, it would be the same as the AC power input failing on a UPS.

 

https://decibel.ni.com/content/docs/DOC-1154

 

I've attached a VI (LabVIEW 8.6) that contains the call to Kernel32.DLL that you can use to read the current state.

 

 

 

Message 5 of 5
(3,241 Views)