Windows 注册表Registry与bat批处理相关

注册表清除Windows运行框里的所有缓存内容

  • 保存为RunMRU.reg 文件,直接导入即可
1
2
3
4
Windows Registry Editor Version 5.00

[-HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RunMRU]
[-HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\TypedPaths]

Windows 开启自动登陆系统,保存为auto.reg.导入即可

1
2
3
4
5
6
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"AutoAdminLogon"="1"
"DefaultUserName"="admin"
"DefaultPassword"="123456"

修改管理员密码

1
2
3
4
5
6
7
8
9
@echo off
cls
color 0A
set /p user=请输入你想要更改密码的用户名:
set /p pass=请输入你想要更改的密码:
net user %user% %pass%
echo %user%
echo %pass%
pause

注册表U2000在Windows 10中安装报错解决

1
2
3
4
5
6
7
8
9
10
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]
"EditionID"="Professional"
"ProductName"="Windows 10 Pro"

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows NT\CurrentVersion]
"EditionID"="Professional"
"ProductName"="Windows 10 Pro"
"CompositionEditionID"="Professional"

注册表Windows OEM

1
2
3
4
5
6
7
8
9
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation]
"Logo"="C:\\Windows\\Web\\Oemlogo.bmp"
"Manufacturer"="QQ 545818"
"Model"="微信 545818"
"SupportURL"="http://www.wlann.cn:88"
"SupportHours"="7×12"
"SupportPhone"="180-1600-1868"

BAT 批处理

  • 手动设置IP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
@echo off
cls
color 0A

set "name="

rem 跳过前两行表头,只取状态列是“已连接”的网卡名
for /f "skip=2 tokens=1,2,3,*" %%a in ('netsh interface show interface') do (
if "%%b"=="已连接" set "name=%%d"
)

echo *******************************************************************************
echo 检测到的网卡名称是: "%name%"
echo *******************************************************************************

rem 如果没取到网卡名,退出
if "%name%"=="" (
echo 错误:未检测到已连接的网卡,请检查网络连接!
pause
exit /b
)

rem 确认是否继续
set /p choice=是否要修改该网卡的IP和DNS?(Y/N):
if /i not "%choice%"=="Y" (
echo 已取消操作。
pause
exit /b
)

echo *******************************************************************************
echo 正在修改IP地址和DNS服务器地址,请耐心等待…………
echo *******************************************************************************

rem 修改 IP 和网关
netsh interface ip set address name="%name%" static 10.20.0.54 255.255.255.0 10.20.0.1

rem 修改主 DNS
netsh interface ip set dns name="%name%" static 10.20.0.254 primary

rem 增加备用 DNS
netsh interface ip add dns name="%name%" 8.8.8.8 index=2

ipconfig /flushdns
netsh winsock reset
ipconfig /all

echo *******************************************************************************
echo OK!!已修改成功!请按任意键继续…………
echo *******************************************************************************
pause
  • dhcp设置IP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

@echo off
cls
color 0A

set "name="

rem 跳过前两行表头,只取状态列是“已连接”的网卡名
for /f "skip=2 tokens=1,2,3,*" %%a in ('netsh interface show interface') do (
if "%%b"=="已连接" set "name=%%d"
)

echo *******************************************************************************
echo 检测到的网卡名称是: "%name%"
echo *******************************************************************************

rem 如果没取到网卡名,退出
if "%name%"=="" (
echo 错误:未检测到已连接的网卡,请检查网络连接!
pause
exit /b
)

rem 确认是否继续
set /p choice=是否要修改该网卡的IP和DNS?(Y/N):
if /i not "%choice%"=="Y" (
echo 已取消操作。
pause
exit /b
)

echo *******************************************************************************
echo 正在修改IP地址和DNS服务器地址,请耐心等待…………
echo *******************************************************************************

Echo *******************************************************************************
Echo 正在修改IP地址和DNS服务器地址,请耐心等待…………
Echo *******************************************************************************
netsh interface ip set address %name% source=dhcp
netsh interface ip set dns %name% source=dhcp
del /f /q a.txt


ipconfig /flushdns
netsh winsock reset
ipconfig /all
Echo *******************************************************************************
Echo OK!!已修改成功!请按任意键继续…………
Echo 谢谢您的使用!QQ 545818
Echo *******************************************************************************
Pause
  • windows 打开ping 和关闭ping
1
2
3
4
5
6
7
echo 进入服务器后 点击 开始——运行 输入命令:
netsh firewall set icmpsetting 8
echo 这样就可以在外部ping到服务器了 非常简单实用!

echo 同样道理,如果想禁止Ping,那运行如下命令即可实现:
netsh firewall set icmpsetting 8 disable
echo 这样就不可以在外部ping到服务器了 非常简单实用!
  • vbs 自动登陆OLT(CMD运行)
    将下面代码保存为auto.vbs文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
on error resume next 
dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.run"cmd"
WshShell.AppActivate"c:\windows\system32\cmd.exe"
WScript.Sleep 200
WshShell.SendKeys"telnet 10.0.50.1"
WshShell.SendKeys"{ENTER}"
WScript.Sleep 100
WshShell.AppActivate"telnet.exe "
WScript.Sleep 2000
WshShell.SendKeys"root"
WshShell.SendKeys"{ENTER}"
WScript.Sleep 2000
WshShell.SendKeys"lt545818"
WshShell.SendKeys"{ENTER}"
WScript.Sleep 2000
WshShell.SendKeys"en"
WshShell.SendKeys"{ENTER}"
WScript.Sleep 2000
WshShell.SendKeys"co"
WshShell.SendKeys"{ENTER}"
WScript.Sleep 1000
WshShell.SendKeys"sw l"
WshShell.SendKeys"{ENTER}"
WScript.Sleep 1000
WshShell.SendKeys"display ont autofind all"
WshShell.SendKeys"{ENTER}"
WScript.Sleep 1000

在 Windows 电脑中,临时 IPv6 地址(隐私扩展)默认是开启的。如果你因为某些特殊需求(例如需要固定 IPv6 方便远程连接、或者排查网络故障)想要关闭它,或者想重新开启,可以通过 PowerShell 或 命令提示符(CMD) 来轻松实现。

  • 以下是具体的配置方法:以管理员身份打开 PowerShell

  • 关闭

1
2
3
4
5
# 禁用临时地址的分配
netsh interface ipv6 set global randomizeidentifiers=disabled

# 关闭隐私扩展功能
netsh interface ipv6 set privacy state=disabled
  • 启用
1
2
3
4
5
# 启用临时地址的分配
netsh interface ipv6 set global randomizeidentifiers=enabled

# 开启隐私扩展功能
netsh interface ipv6 set privacy state=enabled
  • 查看
1
netsh interface ipv6 show privacy
  • 重启网卡
1
netsh interface set interface "Ethernet0" disabled & netsh interface set interface "Ethernet0" enabled