The simplest way I have found to easily switch power modes to manage the machines ability to manage power is by defining Power Schemes. You just go into control panel and create any new power schemes or edit the existing existing predefined schemes. Setup a scheme for how you want the machine to behave normally where it does go to sleep when allowed. For example, on my Windows 7 machines I just edit the predefined "Balanced" power scheme for this. Then edit or create a scheme where the machine runs at full speed / power 100% of the time and is not allowed to sleep. Again, I just edit the existing "High Performance" power scheme and configure it that way. Then once these power schemes are defined you can easily script the mode the machine is running in using the POWERCFG.EXE command line utility.
Pop open a command line window and run:
powercfg -list
... when that runs, you should get a list of all of the machines defined power schemes along with the corresponding GUID value that you will need to note. Then to switch the machine from one power scheme to another, I have a simple batch file / script that I can run which passes the GUID for the scheme I want the machine to be running in. This way in my scheduled tasks and other tools, I can just call one of my scripts to keep the machine running without hibernating or at full speed. The batch file just uses powercfg.exe with the setactive switch to pick which power scheme I want. So this will look something like:
powercfg -setactive 381b4222-f694-41f0-9685-ff5bb260df2e
Just note that the last part is the GUID for your machine that you get by using the above list command.