UAC 不再起作用,一切都被阻止

UAC 不再起作用,一切都被阻止

昨天我(愚蠢地)尝试运行一个批处理脚本,该脚本(理论上)应该重置 WinSock 而无需重新启动系统。

它不起作用。

现在 WiFi 设备不存在了;我无法运行系统的设备管理器;我无法运行 regedit。似乎 UAC 出了问题(我猜)。

这是脚本(来自2014 年 5 月 10 日在 Tweaking.com 上发布的帖子现在似乎可以实现通过 Google 缓存

    @ECHO off
TITLE Full Network Reset [Win 7]
:::::::::::::::::::::::::::::::::::::::::
:: Automatically check & get admin rights
:::::::::::::::::::::::::::::::::::::::::
CLS 
ECHO.
ECHO =============================
ECHO Running Admin shell
ECHO =============================

:checkPrivileges 
NET FILE 1>NUL 2>NUL
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges ) 

:getPrivileges 
if '%1'=='ELEV' (shift & goto gotPrivileges)  
ECHO. 
ECHO **************************************
ECHO Invoking UAC for Privilege Escalation 
ECHO **************************************

setlocal DisableDelayedExpansion
set "batchPath=%~0"
setlocal EnableDelayedExpansion
ECHO Set UAC = CreateObject^("Shell.Application"^) > "%temp%\OEgetPrivileges.vbs" 
ECHO UAC.ShellExecute "!batchPath!", "ELEV", "", "runas", 1 >> "%temp%\OEgetPrivileges.vbs" 
"%temp%\OEgetPrivileges.vbs" 
exit /B 

:gotPrivileges 
::::::::::::::::::::::::::::
:START

ECHO Please save and close everything before proceeding
Pause
ECHO Creating Backup...
MD %HomeDrive%\Backup\etc
MD %HomeDrive%\Backup\Registry
xcopy %windir%\system32\drivers\etc %HomeDrive%\Backup\etc /H /I /Y
Regedit /E %HomeDrive%\Backup\Registry\Registry.reg
REG EXPORT HKLM\System\CurrentControlSet\Services\NetBt\Parameters %HomeDrive%\Backup\Registry\NetBT_Parameters.reg
REG EXPORT HKLM\System\CurrentControlSet\Services\LanmanServer\Parameters %HomeDrive%\Backup\Registry\LanmanServer_Parameters.reg
netsh -c interface dump > %HomeDrive%\Backup\IPBackup.txt
ipconfig /all >> %HomeDrive%\Backup\IPConfig.txt
netsh int ip show config >> %HomeDrive%\Backup\NetshConfig.txt
netsh int ip show addresses >> %HomeDrive%\Backup\Netsh.txt
netsh int ip show dnsservers >> %HomeDrive%\Backup\Netsh.txt
netsh ipsec static show all >> %HomeDrive%\Backup\IPSec.txt
nbtstat -n >> %HomeDrive%\Backup\nbtstat.txt
nbtstat -r >> %HomeDrive%\Backup\nbtstat.txt
whoami /all >> %HomeDrive%\Backup\UserDetails.txt
start %HomeDrive%\Backup\
cls
ECHO Backup Complete...
Pause

cls
ECHO Stopping Services...
net stop Mcx2Svc /y
net stop IPBusEnum /y
net stop HomeGroupProvider /y
net stop FDResPub /y
net stop fdPHost /y
net stop netprofm /y
net stop HomeGroupListener /y
net stop Browser /y
net stop LanmanServer /y
net stop WwanSvc /y
net stop NlaSvc /y
net stop WinHttpAutoProxySvc /y
net stop Dhcp /y
net stop Dnscache /y
net stop iphlpsvc /y
net stop SharedAccess /y
net stop Netman /y
net stop Browser /y
net stop Netlogon /y
net stop SessionEnv /y
net stop LanmanWorkstation /y
net stop nsi /y
net stop dot3svc /y
net stop Wlansvc /y
net stop EapHost /y
net stop KeyIso /y
net stop PolicyAgent /y
net stop lmhosts /y
net stop DPS /y
net stop EventSystem /y

cls
ECHO Resetting Network Environment...

pushd\windows\system32\drivers\etc
attrib -h -s -r hosts
ECHO 127.0.0.1 localhost>HOSTS
attrib +r +h +s hosts
popd

 ::If you can ping a remote computer IP but not the name this may be an outdated NetBIOS name resolution in the local NetBIOS name cache. Reset the cache and force the computer to retrieve remote computer name.
nbtstat -R
nbtstat -RR
REG DELETE HKLM\System\CurrentControlSet\Services\NetBt\Parameters /v NodeType /f
REG DELETE HKLM\System\CurrentControlSet\Services\NetBt\Parameters /v DhcpNodeType /f
REG ADD HKLM\System\CurrentControlSet\Services\LanmanServer\Parameters /v Size /d 3 /f
REG ADD "HKLM\System\CurrentControlSet\Control\Session Manager\Memory Management" /v LargeSystemCache /d 1 /f

 ::Reset the routing table
route /f

 ::Resets Winsock Catalog to a clean state. Restart computer after this one.
netsh winsock reset all
netsh winsock reset catalog

 ::Restores Windows Firewall with Advanced Security policy to the default policy.
netsh advfirewall reset

 :: Deletes all IP Sec Policies
netsh ipsec dynamic delete all

 ::Resets the BranchCache service. Flushes the local cache.
netsh branchcache reset

 ::Flushes ARP Cache
netsh int ip delete arpcache

 ::Resets TCP/IP and related components to a clean state. (IPv4 & IPv6)
netsh int ip reset all
netsh int ipv6 reset all

cls
ECHO Starting Services...
net start EventSystem /y
net start DPS /y
net start lmhosts /y
net start PolicyAgent /y
net start KeyIso /y
net start EapHost /y
net start Wlansvc /y
net start dot3svc /y
net start nsi /y
net start LanmanWorkstation /y
net start SessionEnv /y
net start Netlogon /y
net start Browser /y
net start Netman /y
net start SharedAccess /y
net start iphlpsvc /y
net start Dnscache /y
net start Dhcp /y
net start WinHttpAutoProxySvc /y
net start NlaSvc /y
net start WwanSvc /y
net start LanmanServer /y
net start Browser /y
net start HomeGroupListener /y
net start netprofm /y
net start fdPHost /y
net start FDResPub /y
net start HomeGroupProvider /y
net start IPBusEnum /y
net start Mcx2Svc /y

cls
ECHO Renew IP Settings...
::Release & Renew the IP Configuration & Flush DNS settings.
netsh interface ip set address "Local Area Connection" dhcp 
ipconfig /release
ipconfig /flushdns
netsh interface ip set address "Local Area Connection" dhcp
ipconfig /renew
ipconfig /registerdns

cls
ECHO Operation Completed...
ECHO. 
ECHO Reboot computer if network not accessible...
PAUSE
REM To restart PC afterwards enable the following command: shutdown -r -t 1
Windows XP 
Code: [Select]
@ECHO OFF
TITLE Full Network Reset [Win XP]
::Network Reset Windows XP

ECHO Creating Backup...
MD %HomeDrive%\Backup\etc
MD %HomeDrive%\Backup\Registry
xcopy %windir%\system32\drivers\etc %HomeDrive%\Backup\etc /H /I /Y
Regedit /E %HomeDrive%\Backup\Registry\Registry.reg
REG EXPORT HKLM\System\CurrentControlSet\Services\NetBt\Parameters %HomeDrive%\Backup\Registry\NetBT_Parameters.reg
REG EXPORT HKLM\System\CurrentControlSet\Services\LanmanServer\Parameters %HomeDrive%\Backup\Registry\LanmanServer_Parameters.reg
netsh -c interface dump > %HomeDrive%\Backup\IPBackup.txt
ipconfig /all >> %HomeDrive%\Backup\IPConfig.txt
netsh int ip show config >> %HomeDrive%\Backup\NetshConfig.txt
netsh int ip show addresses >> %HomeDrive%\Backup\Netsh.txt
netsh int ip show dnsservers >> %HomeDrive%\Backup\Netsh.txt
nbtstat -n >> %HomeDrive%\Backup\nbtstat.txt
nbtstat -r >> %HomeDrive%\Backup\nbtstat.txt
start %HomeDrive%\Backup\
ECHO Backup Complete...
Pause

cls
ECHO Stopping Services...
:: Application Layer Gateway Service - Manual   - No Dependencies
Net Stop ALG /Y
::Background Intelligent Transfer Service - Manual  - No Dependencies
Net Stop BITS /Y
:: DHCP Client - Automatic - No Dependencies.
Net Stop DHCP /Y
::Distributed Link Tracking Client - Automatic - No Dependencies
Net Stop TrkWks /Y
::DNS CLient - Automatic - No Dependencies
Net Stop Dnscache /Y
::Indexing Service - Manual - No Dependencies
Net Stop CiSvc /Y
::IPSEC Services - Automatic - No Dependencies
Net Stop PolicyAgent /Y
::Network Location Awareness (NLA) - Manual - No Dependencies
Net Stop Nla /Y
::QoS RSVP - Manual - No Dependencies
Net Stop RSVP /Y
::Universal Plug and Play Device Host - Manual - No Dependencies
Net Stop upnphost /Y
::SSDP Discovery Service - Manual - Universal Plug & Play Device Host
Net Stop SSDPSRV /Y
::TCP/IP NetBIOS Helper - Automatic - No Dependencies
Net Stop LmHosts /Y
::Remote Access Auto Connection Manager - Manual - No Dependencies
Net Stop RasAuto /Y
::Remote Access Connection Manager - Manual - RasAuto
Net Stop RasMan /Y
::Telephony - Manual - RasAuto & RasMan
Net Stop TapiSrv /Y
::WebClient - Automatic - No Dependencies
Net Stop WebClient /Y
::Windows Firewall/Internet Connection Sharing (ICS) - Automatic - No Dependencies
Net Stop SharedAccess /Y
::Network Connections - Manual - Windows Firewall/Internet Connection Sharing.
Net Stop Netman /Y
::Wired AutoConfig - Manual - No Dependencies
Net Stop Dot3svc /Y
::Extensible Authentication Protocol Service - Manual - Wired Autoconfig
Net Stop EapHost /Y
::Wireless Zero Configuration - Automatic - No Dependencies
Net Stop WZCSVC /Y
::Alerter - Disabled - No Dependencies
Net Stop Alerter /Y
::Computer Browser - Automatic  - No Dependencies.
Net Stop Browser /Y
::Server - Automatic - Computer Browser
Net Stop LanmanServer /Y
::Messenger - Disabled - No Dependencies
Net Stop Messenger /Y
::Net Logon - Manual - No Dependencies
Net Stop Netlogon /Y
::Remote Procedure Call (RPC) Locator - Manual - No Dependencies
Net Stop RpcLocator /Y
::Workstation - Automatic - Alerter, Computer Browser, Messenger, Net Logon, RPC Locator
Net Stop lanmanworkstation /Y

cls
ECHO Resetting Network Environment...

pushd\windows\system32\drivers\etc
attrib -h -s -r hosts
ECHO 127.0.0.1 localhost>HOSTS
attrib +r +h +s hosts
popd

 ::If you can ping a remote computer IP but not the name this may be an outdated NetBIOS name resolution in the local NetBIOS name cache. Reset the cache and force the computer to retrieve remote computer name.
nbtstat -R
nbtstat -RR
REG DELETE HKLM\System\CurrentControlSet\Services\NetBt\Parameters /v NodeType /f
REG DELETE HKLM\System\CurrentControlSet\Services\NetBt\Parameters /v DhcpNodeType /f
REG ADD HKLM\System\CurrentControlSet\Services\LanmanServer\Parameters /v Size /d 3 /f
REG ADD "HKLM\System\CurrentControlSet\Control\Session Manager\Memory Management" /v LargeSystemCache /d 1 /f

 ::Reset the routing table
route /f

 ::Resets Winsock Catalog to a clean state. Restart computer after this one.
netsh winsock reset all
netsh winsock reset catalog

 ::Restores Windows Firewall with Advanced Security policy to the default policy.
netsh firewall reset

 ::Flushes ARP Cache
netsh int ip delete arpcache

 ::Resets TCP/IP and related components to a clean state. (IPv4 & IPv6)
netsh int ip reset all
netsh int ipv6 reset all

cls
ECHO Starting Services...
Net Start ALG /Y
Net Start BITS /Y
Net Start DHCP /Y
Net Start TrkWks /Y
Net Start Dnscache /Y
Net Start CiSvc /Y
Net Start PolicyAgent /Y
Net Start Nla /Y
Net Start RSVP /Y
Net Start upnphost /Y
Net Start SSDPSRV /Y
Net Start LmHosts /Y
Net Start RasAuto /Y
Net Start RasMan /Y
Net Start TapiSrv /Y
Net Start WebClient /Y
Net Start SharedAccess /Y
Net Start Netman /Y
Net Start Dot3svc /Y
Net Start EapHost /Y
Net Start WZCSVC /Y
Net Start Alerter /Y
Net Start Browser /Y
Net Start LanmanServer /Y
Net Start Messenger /Y
Net Start Netlogon /Y
Net Start RpcLocator /Y
Net Start lanmanworkstation /Y

cls
ECHO Renew IP Settings...
::Release & Renew the IP Configuration & Flush DNS settings.
ipconfig /release
ipconfig /flushdns
netsh interface ip set address "Local Area Connection" dhcp 
ipconfig /renew
ipconfig /registerdns

ECHO Operation Completed...
ECHO. 
ECHO Reboot computer if network not accessible...
PAUSE

脚本备份了所有内容,但我不知道要恢复什么(以及如何恢复)。有许多文本文件和一些 files.reg(如果我尝试运行,它们显然会冻结资源管理器)。

如何在不格式化的情况下恢复 UAC 和设备?

相关内容