Solved

Window xp powercfg.exe script

Posted on 2014-04-07
9
920 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 43

Expert Comment

by:Rob
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 43

Expert Comment

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

Featured Post

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

734 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