Solved

Script or batch to turn off or tweak windows settings

Posted on 2014-12-13
5
443 Views
Last Modified: 2015-01-02
I need a script or batch that I can run on Windows 7/8/2003/2008 that will do the following...

Turn off and disable Windows firewall

Adjust 'balanced' power options to turn off display after 30 mins and put the computer to sleep 'never', when plugged in.
0
Comment
Question by:murryc
[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
  • 2
  • 2
5 Comments
 
LVL 18

Expert Comment

by:Simon
ID: 40498016
They all sound like things that you'd do through Group Policy - are these devices not on a AD domain?
0
 
LVL 96

Accepted Solution

by:
Lee W, MVP earned 500 total points
ID: 40498088
Group Policy is definitely the way you should be doing this.  If that's not possible for some reason, the user will need to run the script as an administrator -
@ECHO OFF
REM Save the currently active scheme to "ActiveScheme" variable so we can restore it.
for /f "tokens=4" %%a in ('powercfg -getactivescheme') do @Set ActiveScheme=%%a
REM Set the Balanced power scheme to active so we can change settings
powercfg -setactive 381b4222-f694-41f0-9685-ff5bb260df2e

REM Change the necessary AC settings
powercfg -change -monitor-timeout-ac 30
powercfg -change -standby-timeout-ac 0
powercfg -change -hibernate-timeout-ac 0

REM Restore the power scheme
powercfg -setactive %ActiveScheme%

REM Disable the fire wall - use enable instead of disable to re-enable
netsh advfirewall set allprofiles state off

Open in new window


Test the above first - I have not.
0
 

Author Comment

by:murryc
ID: 40520449
This will be used on standalone systems, so local GPO would work okay, but I am looking to automate these steps.

Lee, the batch tweaks the power options ok, but the firewall is not changing its state to disabled and the service is not stopping.  Do I need to insert something into your batch?
0
 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 40520833
Run the netsh command separately and check for errors.  Review the event logs.  I just tested that command and its working fine.
0
 

Author Comment

by:murryc
ID: 40528129
You were correct.  Thanks!
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

690 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