Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: Need help with a batch file for energy monitoring

01 Sep 2010   #1

Windows 7 Enterprise 32 bit
Need help with a batch file for energy monitoring

Hi all,

I just got upgraded from XP to Windows 7 at the office (on a Lenovo T500 laptop). I've been fiddling around for the past few hours with efficiency settings to make everything smooth and fast.

During my searches, I ran across this site which could possibly help with battery life and thought it would be cool if I could semi-automate it: Make Windows 7 Be More Efficient & Have Better Battery Life | OS Attack

In the bat file, I wanted to do the following:
1. Get the current date and time.
2. Navigate to the System32 directory.
3. Execute the powercfg application with the output file having the current date and time.

I'm mediocre with bats so Google aided me in coming up with this:
Set DATESTAMP=%DATE:~10,4%-%DATE:~4,2%-%DATE:~7,2%
Set TIMESTAMP=%TIME:~0,2%-%TIME:~3,2%-%TIME:~6,2%

Echo Date and time: %DATEANDTIME%
CD C:\Windows\System32
powercfg.exe -energy -output C:\Users\rmaharaj\Documents\Energy Reports\EnergyReport_%DATEANDTIME%.html
Unfortunately, the -energy switch needs the command prompt to be running as an Administrator.

I tried finding out how to have the batch file open a command prompt in as an Admin. This is the command I was able to come up with:
PowerShell -Command (New-Object -com 'Shell.Application').ShellExecute('CMD.EXE','C:\Windows\System32','','runas')
But I'm not able to:
1. get the rest of it to run in the newly opened command prompt
2. close both the old and new command prompt when they are completed

Can someone please help with this?

Thanks in advance!!

Attached Files
File Type: bat test.bat (507 Bytes, 4 views)
My System SpecsSystem Spec


 Need help with a batch file for energy monitoring

Thread Tools

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 11:43 PM.
Twitter Facebook Google+

Windows 7 Forums

Seven Forums Android App Seven Forums IOS App

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33