Solved

Window xp powercfg.exe script

Posted on 2014-04-07
9
837 Views
Last Modified: 2014-04-30
Hi,
I've create a script which change power profile name and edit 5 minutes in turn off power monitor.this script i've configured in group policy.it working well on all user Active directory profile.

script is
@echo off
Powercfg.exe /CREATE "Power Saving"
Powercfg.exe /CHANGE "Power Saving" /monitor-timeout-ac-5
Powercfg.exe /SETACTIVE "Power Saving"
Hostname >> C:\Hostname.txt

Now the issue, i want to configure if else statement in it.
like:-if script work then it create a file in C: drive and print computer name & PASS msg in file.if suppose script not run in user profile then print computer name & Fail msg in file.

i hope you understand what i'm saying.

Thanks,
0
Comment
Question by:xeroxzerox
  • 3
  • 2
  • 2
9 Comments
 
LVL 13

Accepted Solution

by:
stergium earned 500 total points
ID: 39982459
Hello.
to my understanding your problem can be solved with checking the error level after the last powercfg.exe
if %errorlevel% equ 1 (
echo " fail"  >> c:\hostname.txt
) else (
echo "pass" >> c:\hostname.txt
)
i hope that helps
0
 
LVL 6

Author Comment

by:xeroxzerox
ID: 39982478
Hi,

@echo off
Powercfg.exe /CREATE "Power Saving"
Powercfg.exe /CHANGE "Power Saving" /monitor-timeout-ac-5
Powercfg.exe /SETACTIVE "Power Saving"
if %errorlevel% equ 1 (
echo " fail"  >> c:\hostname.txt
) else (
echo "pass" >> c:\hostname.txt
)

I've execute this script but it unable to create file.
0
 
LVL 13

Expert Comment

by:stergium
ID: 39982486
that is a bit odd.
try ommiting the c:\ (for debugging purposes only) and feedback the results please.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 6

Author Comment

by:xeroxzerox
ID: 39982493
i'm unable to understand, you mean is
if %errorlevel% equ 3

but now i've change the errorlevel to 2
now file create in c drive and it print hostname and pass.i've check power setting in control panal.it fine.
Now if i run again this script,it should give me fail or print fail msg in file because setting already implemented before running this script.
but it print pass in both conditions.
0
 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 40025120
Now if i run again this script,it should give me fail or print fail msg in file because setting already implemented before running this script.
but it print pass in both conditions.

I can understand why you'd think this but it's not the case.  The script runs fine and POWERCFG is able to set the power config even if it is the same setting.  So as far as POWERCFG is concerned there is no error.

make sense?
0
 
LVL 6

Author Closing Comment

by:xeroxzerox
ID: 40031284
Thanks
0
 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 40031405
Can you clarify exactly what the solution is as you've accepted the first post.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now