I work for a company and they want us to create a script to reset all network settings in cases like with the Windows 10 update that "broke" the network where you had to run a netsh winsock reset. We at the shop created a script and it works wonderful.
@echo off
goto check_Permissions
:check_Permissions
echo --------------------------------------------------------------------------------
echo This script was originally created by Adam, but modified and edited by Steven.
echo --------------------------------------------------------------------------------
echo Administrative permissions required. Detecting permissions...
net session >nul 2>&1
if %errorLevel% == 0 (
echo Success: Good job you did it right! Press any key to continue....
) else (
echo Failure: !!!!!!!!!!!DO NOT CONTINUE!!!!!!!!!!!! You are not using Administrative privlages. !!!!!!!!!!!DO NOT CONTINUE!!!!!!!!!!!!
)
pause >nul
echo Starting Netsh Dump...
start /wait netsh dump
echo Starting NBTSTAT...
start /wait nbtstat -R
echo Resetting Interface IP.
start /wait netsh int ip reset reset.log
echo Resetting Winsock...
start /wait netsh winsock reset
echo Resetting IPV4 settings...
start /wait netsh int ipv4 reset
echo Resetting IPV6 settings...
start /wait netsh int ipv6 reset
echo Resetting 6to4...
start /wait netsh int 6to4 reset all
echo Resetting HTTP Tunnel...
start /wait netsh int httpstunnel reset all
echo Resetting Port Proxy...
start /wait net int portproxy reset all
echo Releasing IP...
start /wait ipconfig /release
echo Renewing IP...
start /wait ipconfig /renew
echo Flushing DNS...
start /wait ipconfig /flushdns
echo Registering DNS...
start /wait ipconfig /registerdns
pause
Goes through and does everything we need it to do. My boss came by the other day and asked us; 'So what do you do if they have a static IP or even Proxy on their computer and you just erased all of that without obtaining that information. As well, where are the logs of what you did? Every time you should run this script there should be logs on what the script did. Not just on the console.'
Good point... So, I've been tweaking with it for a while and I'm unable to make the script output into a log file, I've tried >> Logs.txt, I've tried > Logs.txt, I've tried everything that I can find and nothing. We also rewrote the script to make it a little less clustery... Which is posted below.
@echo off
goto check_Permissions
:check_Permissions
echo --------------------------------------------------------------------------------
echo This script was originally created by Adam, but modified and edited by Steven.
echo --------------------------------------------------------------------------------
echo Administrative permissions required. Detecting permissions...
net session >nul 2>&1
if %errorLevel% == 0 (
echo Success: Good job you did it right! Press any key to continue....
) else (
echo Failure: !!!!!!!!!!!DO NOT CONTINUE!!!!!!!!!!!! You are not using Administrative privlages. !!!!!!!!!!!DO NOT CONTINUE!!!!!!!!!!!!
)
pause >nul
echo Starting Networking Reset...
netsh dump && nbtstat -R && netsh int ip reset reset.log && netsh winsock reset && nbtstat -R && netsh int ip reset && netsh int 6to4 reset all && netsh int httpstunnel reset all && net int portproxy reset all && ipconfig /flushdns
pause
Basically I just want it to output a file saying what all was done and if at all possible a scan that detects if they have a static IP//proxies set up in the network BEFORE running this script...
Cheers, Mittens.