批处理脚本(Batch files)是Windows操作系统中用于自动化任务的脚本。以下是一些常用的批处理脚本示例,它们可以帮助你执行各种常见的任务:1. 清理临时文件@echo off echo C
批处理脚本(Batch files)是Windows操作系统中用于自动化任务的脚本。以下是一些常用的批处理脚本示例,它们可以帮助你执行各种常见的任务:
@echo off
echo Cleaning temporary files...
del /q /f /s %temp%\*
echo Done!
pause
@echo off
set "source=C:\MyFolder"
set "backup=D:\Backup\MyFolder"
robocopy "%source%" "%backup%" /e /z /r:3 /w:5
echo Backup completed.
pause
@echo off
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v AUOptions /t REG_DWORD /d 1 /f
echo Windows Update has been disabled.
pause
@echo off
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v AUOptions /t REG_DWORD /d 3 /f
echo Windows Update has been enabled.
pause
@echo off
set "wallpaper=C:\Pictures\MyWallpaper.jpg"
reg add "HKCU\Control Panel\Desktop" /v Wallpaper /t REG_SZ /d "%wallpaper%" /f
echo Desktop background changed.
pause
@echo off
set "hidden=0"
reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" | findstr /i "HideFileExt" > nul
if %errorlevel% equ 0 (
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v HideFileExt /t REG_DWORD /d %hidden% /f
) else (
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v HideFileExt /t REG_DWORD /d 2 /f
)
echo File extensions %if%hidden.
pause
@echo off
set "policy=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
set "value=DisableCAD"
reg query "%policy%" | findstr /i "%value%" > nul
if %errorlevel% equ 0 (
reg delete "%policy%" /v "%value%" /f
echo Ctrl+Alt+Del login screen has been enabled.
) else (
reg add "%policy%" /v "%value%" /t REG_DWORD /d 1 /f
echo Ctrl+Alt+Del login screen has been disabled.
)
pause
@echo off
ping -n 4 127.0.0.1 > nul
if %errorlevel% equ 0 (
echo You are connected to the network.
) else (
echo You are not connected to the network.
)
pause
@echo off
for /f "skip=1 tokens=2 delims=[]" %%i in ('systeminfo /fo table /s') do set "%%i"
echo.
echo System Information:
echo OS Name: %OSName%
echo OS Version: %OSVersion%
echo Installed RAM: %TotalPhys%
echo.
pause
@echo off
shutdown /s /f /t 0
echo Computer will shut down immediately.
pause
请注意,一些脚本可能需要管理员权限才能执行,特别是那些涉及更改系统设置的脚本。在运行任何脚本之前,请确保你理解脚本的内容和它将执行的操作,以避免不必要的系统问题。此外,对于涉及修改注册表的脚本,请谨慎使用,因为不正确的注册表更改可能会导致系统不稳定或无法启动。
暂无管理员
粉丝
0
关注
0
收藏
0