Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 对网络脚本进行一些更改_Batch File - Fatal编程技术网

Batch file 对网络脚本进行一些更改

Batch file 对网络脚本进行一些更改,batch-file,Batch File,我在一家公司工作,他们希望我们创建一个脚本来重置所有网络设置,例如Windows 10更新“破坏”了网络,您必须运行netsh winsock重置。我们在商店创作了一个剧本,效果非常好 @echo off goto check_Permissions :check_Permissions echo -------------------------------------------------------------------------------- echo T

我在一家公司工作,他们希望我们创建一个脚本来重置所有网络设置,例如Windows 10更新“破坏”了网络,您必须运行netsh winsock重置。我们在商店创作了一个剧本,效果非常好

    @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
完成了我们需要它做的一切。前几天,我的老板过来问我们:“我的老板是谁?”那么,如果他们的计算机上有一个静态IP甚至是代理,而你只是删除了所有这些而没有获得这些信息,你该怎么办呢。还有,你所做的记录在哪里?每次运行此脚本时,都应该记录脚本所做的操作。不仅仅是在控制台上。”

说得好。。。所以,我已经调整了一段时间,但我无法将脚本输出到日志文件中,我尝试了>>Logs.txt,我尝试了>>Logs.txt,我尝试了所有我能找到的东西,但什么都没有。我们还重写了脚本,使其不那么混乱。。。贴在下面

 @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
基本上,我只想让它输出一个文件,说明所有的工作都完成了,如果可能的话,在运行这个脚本之前,扫描检测他们是否在网络中设置了静态IP//代理

干杯,
手套。

为了让它成为一个可点击的过程,我将两个bat文件串在一起。2个蝙蝠,如下图所示,我会单击
batthattriggersyorscript.bat
使其运行

batthattriggersyorscript.bat

CheckPermissions.bat > OurLog.log
checkpermissions.bat

All that code you already have
要在cmd行中手动执行,那么我每次都会删除字符串并自己编写…真是太棒了

CheckCheckPermissions.bat > MyLog.log

作为旁注,
写入一个新文件,而
>
附加到一个文件。

对于问题的日志部分,您可能对Dave Benham模拟Unix
tee
命令感兴趣。