Solved

Script or batch to turn off or tweak windows settings

Posted on 2014-12-13
5
418 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
  • 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 95

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 95

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
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 …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

775 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