bat 文件执行cmd命令的几个应用(一)
注:以下所有
bat
命令,均可在 🌏 本站下载 - 按需下载即可!**
bat
文件创建方式:新建文本文件,写入相应命令,另存为.bat
文件,编码修改为ANSI
即可!
强制关闭或开启系统自动更新
- 关闭系统自动更新
@echo off
del /F /S /Q /A C:\Windows\SoftwareDistribution\Download\*
rd /S /Q C:\Windows\SoftwareDistribution\Download
md C:\Windows\SoftwareDistribution\Download
echo y|cacls "C:\Windows\SoftwareDistribution\Download" /e /p SYSTEM:N
echo y|cacls "C:\Windows\SoftwareDistribution" /e /p SYSTEM:N
net stop wuauserv
sc config wuauserv start= disabled
pause
- 开启系统自动更新
@echo off
echo y|cacls "C:\Windows\SoftwareDistribution\Download" /e /p SYSTEM:F
echo y|cacls "C:\Windows\SoftwareDistribution" /e /p SYSTEM:F
sc config wuauserv start= auto
net start wuauserv
pause
配合 NetFx3.cab
安装 NET 3.5
- 🌏 NetFx3.cab 下载
@echo off
echo.
md C:\source\sxs
echo y|cacls "C:\Windows\SoftwareDistribution\Download" /e /p SYSTEM:F
echo y|cacls "C:\Windows\SoftwareDistribution" /e /p SYSTEM:F
sc config wuauserv start= auto
net start wuauserv
echo.
set net=%~dp0
copy %net%NetFx3.cab C:\source\sxs\NetFx3.cab
echo.
dism.exe /online /enable-feature /featurename:netfx3 /Source:C:\sources\sxs
echo.
rd /S /Q C:\source
echo y|cacls "C:\Windows\SoftwareDistribution\Download" /e /p SYSTEM:N
echo y|cacls "C:\Windows\SoftwareDistribution" /e /p SYSTEM:N
net stop wuauserv
sc config wuauserv start= disabled
pause
Win10右下角时间精确到秒
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "ShowSecondsInSystemClock" /t REG_DWORD /d 1 /f
taskkill /f /im explorer.exe
start explorer
pause
文件名获取
- 无序
@echo off
echo.
echo 请稍候……
echo.
for /f "delims=" %%a in ('dir /b') do echo %%a >>name.txt
echo 已在当前目录生成name.txt,包含当前目录的所有文件夹/文件名
echo.
echo 生成的信息中包含了文件名获取.bat,按需要删除!!!
echo.
pause
- 按文件修改时间倒序获取
@echo off
echo.
echo 请稍候……
echo.
for /f "delims=" %%a in ('dir /b /o-d') do echo %%a >>dx_name.txt
echo 已在当前目录生成name.txt,包含当前目录的所有文件夹/文件名
echo.
echo 生成的信息中包含了文件名获取.bat,按需要删除!!!
echo.
pause
- 按文件修改时间正序获取
@echo off
echo.
echo 请稍候……
echo.
for /f "delims=" %%a in ('dir /b /o:d') do echo %%a >>zx_name.txt
echo 已在当前目录生成name.txt,包含当前目录的所有文件夹/文件名
echo.
echo 生成的信息中包含了文件名获取.bat,按需要删除!!!
echo.
pause
- 文件名获取并生成取消或隐藏bat文件
@echo off
rem 法一:dir /b *.*>>当前目录所有文件夹/文件名.txt
rem 法一、法二使用方法,将法一法二的命令保存到bat文件中即可
rem 法二:在获取的文件名前面增加数据,例如:
echo @echo off>>彻底隐藏文件.bat
for /f "delims=" %%a in ('dir /b') do echo attrib +s +r +h %~dp0%%a >>彻底隐藏文件.bat
echo attrib +s +r +h %~dp0取消文件彻底隐藏.bat>>彻底隐藏文件.bat
echo attrib -a -s -r -h %~dp0文件名获取并生成取消或隐藏bat文件.bat>>彻底隐藏文件.bat
echo pause>>彻底隐藏文件.bat
echo @echo off>>取消文件彻底隐藏.bat
for /f "delims=" %%a in ('dir /b') do echo attrib -a -s -r -h %~dp0%%a >>取消文件彻底隐藏.bat
echo pause>>取消文件彻底隐藏.bat
echo.
echo 操作完成……
echo.
pause
遍历当前文件夹下所有目录名字,包含子目录
@echo off
for /f "delims=" %%i in ('dir /ad/b/s "%~dp0"') do (echo "%%i") >> list.txt
pause
按文件格式批量修改文件名
@echo off
echo.
set /p i=请输入文件格式(即扩展名并以回车结束):
echo.
set /p o=请输入要改成的文件名字(以回车结束):
echo.
set a=0
setlocal EnableDelayedExpansion
for %%n in (*.%i%) do (
set /A a+=1
ren "%%n" "%o%!a!.%i%"
)
endlocal
echo 文件重命名成功!
echo.
pause
复制指定文件到某目录下
@echo off
set /p f=请输入起始文件夹:
set /p m=请输入目标文件夹:
set /p i=请输入文件格式:
pushd %f%
for /r %%a in (*.%i%) do (
XCOPY /Y "%%a" "%m%"
)
popd
pause
去掉或恢复桌面快捷方式小箭头
- 去掉小箭头
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Icons" /v 29 /d "%systemroot%\system32\imageres.dll,197" /t reg_sz /f
taskkill /f /im explorer.exe
attrib -s -r -h "%userprofile%\AppData\Local\iconcache.db"
del "%userprofile%\AppData\Local\iconcache.db" /f /q
start explorer
pause
- 恢复小箭头
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Icons" /v 29 /f
taskkill /f /im explorer.exe
attrib -s -r -h "%userprofile%\AppData\Local\iconcache.db"
del "%userprofile%\AppData\Local\iconcache.db" /f /q
start explorer
pause
删除多个文件夹中的同名文件
@echo off
rem 第一个括号为盘符/路径以逗号隔开(或%~dp0),第二个括号为文件名(需要带后缀)以逗号隔开
for %%l in (c:) do cd /d %%l & for %%j in (filename1,filename2,filename3) do del %%j /a HS /F /S
pause
删除某个盘符或某个文件夹下的同名子文件夹
@echo off
rem C:\ 为盘符,也可以为某个文件夹(或%~dp0),括号内容为文件夹名字
for /d /r C:\ %%b in (*filename1,filename2,filename3*) do rd /s /q "%%b"
pause
删除我的电脑中的OneDrive
reg delete "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" /f
删除我的电脑中的WPS云文档
reg delete "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{5FCD4425-CA3A-48F4-A57C-B8A75C32ACB1}" /f
reg delete "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{7AE6DE87-C956-4B40-9C89-3D166C9841D3}" /f
删除我的电脑中的百度云图标
reg delete "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{679F137C-3162-45da-BE3C-2F9C3D093F64}" /f
删除我的电脑中的微云图标
reg delete "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{3B11AB24-9AF1-45f3-8998-9BCF061D13D8}" /f
修改系统OEM信息
- 删除系统oem信息
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation" /v LOGO /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation" /v Manufacturer /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation" /v Model /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation" /v SupportHours /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation" /v SupportPhone /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation" /v SupportURL /f
- 修改系统OEM信息
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation" /v LOGO /t REG_SZ /d "C:\Windows\System32\oobe\mune.bmp" /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation" /v Manufacturer /t REG_SZ /d "MUNE" /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation" /v Model /t REG_SZ /d "Demo" /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation" /v SupportHours /t REG_SZ /d "24小时技术支持" /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation" /v SupportPhone /t REG_SZ /d "联系电话:18989898989 QQ:909090900" /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation" /v SupportURL /t REG_SZ /d "https://cnxiaobai.com/" /f
@echo off
echo.
set log=%~dp0
copy %log%mune.bmp C:\Windows\System32\oobe\mune.bmp
echo.
echo 系统oem信息修改成功,右键点击计算机选择属性查看!
echo.
pause
Win10开机默认打开数字小键盘
reg add "HKEY_USERS\.DEFAULT\Control Panel\Keyboard" /v InitialKeyboardIndicators /d "80000002" /f
获取连接过的WiFi的密码
@echo off
echo.
echo 请稍后……
echo.
for /f "skip=9 tokens=1,2 delims=:" %%i in ('netsh wlan show profiles') do (@echo %%j | findstr -i -v echo | netsh wlan show profiles %%j key=clear >> %~dp0password.txt)
echo 已在%~dp0目录下生成password.txt,程序将自动打开password.txt
echo.
echo 或后期双击打开password.txt即可查看密码!
start %~dp0password.txt
echo.
pause
解决复制文件到C盘需要权限
icacls c:\ /setintegritylevel M
pause
解决 Windows 7
打开WLAN AutoConfig
服务错误:1747
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Ndisuio" /v DisplayName /t REG_SZ /d "NDIS Usermode I/O Protocol" /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Ndisuio" /v Start /t REG_DWORD /d 2 /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NDIS" /v ErrorControl /t REG_DWORD /d 1 /f
netsh winsock reset
@echo off
echo.
echo 配置成功!
echo.
pause
解决 PS2018
首选项出现要求96和8之间的整数
@echo off
reg add "HKEY_CURRENT_USER\Software\Adobe\Photoshop\120.0" /v OverridePhysicalMemoryMB /t REG_DWORD /d "131072" /f
pause
解决 Office 2010
打开出现配置
reg add "HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Word\Options" /v NoRereg /t REG_DWORD /d 1
@echo off
echo.
echo 修复成功,请重新打开office软件!
echo.
pause
图标缓存一键修复工具
taskkill /f /im explorer.exe
REM 清理系统图标缓存数据库
attrib -h -s -r "%userprofile%\AppData\Local\IconCache.db"
del /f "%userprofile%\AppData\Local\IconCache.db"
attrib /s /d -h -s -r "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\*"
del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_32.db"
del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_96.db"
del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_102.db"
del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_256.db"
del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_1024.db"
del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_idx.db"
del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_sr.db"
REM 清理 系统托盘记忆的图标
echo y|reg delete "HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify" /v IconStreams
echo y|reg delete "HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify" /v PastIconsStream
REM 重启Windows外壳程序explorer.exe
start explorer
REM 批处理代码结束
pasue
删除电脑中的空文件夹
- 删除指定目录下所有空文件夹
@echo off
for /f "delims=" %%a in ('dir /ad /b /s F:^|sort /r') do (
rd "%%a">nul 2>nul &&echo 空目录"%%a"成功删除!
)
pause
- 删除多个磁盘的空文件夹
@echo off
for %%i in (c d e f) do (
if exist %%i: (
for /f "delims=" %%a in ('dir /ad /b /s "%%i:"^|sort /r') do (
rd "%%a"
)
)
)
pause
评论
0 评论