批处理代码文件是ANSI格式,在Win11 23H2系统下显示是正常的ANSI编码,但是在24H2或者最新版本的记事本中显示为UTF-8,且中文内容全部为乱码,修改文件只能用第三方软件修改。
经过反复尝试删减和测试,发现只要删除下面3行内容的任意一行即可解决,有没有大佬能看出问题所在,还请解答一下造成问题的原因:
if %today% GTR 2030 (date 2024-12-12)
::===========BIOSDATESET==============
::===========BIOSDATESET==============
之前有一段代码在AMD处理器搭配铭瑄B450主板,会出现不执行的情况,后面也是修改了代码语句才可以正常使用。当时怀疑是CPU指令集出错导致的,但是找不到验证办法。
下面是全部代码:- @echo off & setlocal enabledelayedexpansion
- set today=%date:~0,4%
- if %today% GTR 2030 (date 2024-12-12)
- ::===========BIOSDATESET==============
- for /f "tokens=1-3 delims=/" %%a in ('echo %date%') do (
- set "sysdate_y=%%a"
- set "sysdate_m=%%b"
- set "sysdate_d=%%c"
- set "sysdate_y=!sysdate_y: =!"
- set "sysdate_m=!sysdate_m: =!"
- set "sysdate_d=!sysdate_d: =!"
- )
- call C:\intel\10\cpuz_x64.exe -txt=1
- for /f "tokens=1,2" %%a in ('type C:\intel\10\1.txt ^|find /i "date" ^|find /i "/" ^|find /i "/"') do (
- if "%%a" equ "date" set "biosdate=%%b"
- )
- for /f "tokens=1-3" %%a in ('type C:\intel\10\1.txt ^|find /i "speed" ^|find /i "MHz"') do (
- if "%%a" equ "speed" set "MemorySpeed=%%b%%c"
- )
- for /f "tokens=1-3 delims=/" %%a in ('echo !biosdate!') do (
- set "biosdate=%%c/%%a/%%b"
- set "biosdate_y=%%c"
- set "biosdate_m=%%a"
- set "biosdate_d=%%b"
- set "biosdate_y=!biosdate_y: =!"
- set "biosdate_m=!biosdate_m: =!"
- set "biosdate_d=!biosdate_d: =!"
- )
- echo,!sysdate_y!
- echo,!biosdate_y!
- if !sysdate_y! gtr !biosdate_y! (set biosdate=!biosdate!_需刷BIOS)
- if !sysdate_y! equ !biosdate_y! (if !biosdate_m! lss 08 (set biosdate=!biosdate!_需刷BIOS))
-
- set "textFile=C:\Intel\11Home_Log.txt"
- call C:\intel\10\sed.exe -i "s#Update=BIOSDATE#Update=!biosdate!#g" %textFile%
- call C:\intel\10\sed.exe -i -i "s#_需刷BIOS##g" "%textFile%"
- call C:\intel\10\sed.exe -i "s#\([0-9]\{4\}\/[0-9]\{2\}\/[0-9]\{2\}\)#%biosdate%#g" %textFile%
- ::===========BIOSDATESET==============
- Start /min C:\intel\10\Motherboardinfo.exe
- ::for /f "tokens=3 delims=, " %%a in ('echo ^|pnputil /enum-devices /disconnected ^|find "实例 ID:"') do echo 移除设备:%%a & pnputil /remove-device "%%a" >nul
- if exist C:\OA3.BIN (goto End)
- cls
- Start /min C:\Intel\10\info\C-D.bat
-
- for %%d in (E F G H I J K L M N O P Q R S T U V W X Y Z) do (if exist %%d:\Autorun.inf (if exist %%d:\Setup.exe (call %%d:\Setup.exe) ))
- for /f "tokens=* delims=, " %%a in ('powershell -Command "Get-NetAdapter | Select-Object -ExpandProperty InterfaceDescription" ^|find /i "Realtek 8811CU Wireless LAN 802.11ac USB NIC"') do set "U9=%%a"
- for /f "tokens=* delims=, " %%a in ('powershell -Command "Get-NetAdapter | Select-Object -ExpandProperty InterfaceDescription" ^|find /i "Realtek RTL8192EU Wireless LAN 802.11n USB 2.0 Network Adapter"') do set "U3=%%a"
- if defined U9 (
- echo 存在无线网卡设备U9
- netsh wlan add profile filename="C:\RWorker_Test\Pwork_1_5G.xml"
- netsh wlan set profileparameter name="Pwork_1_5G" connectionmode=auto
- )
- if defined U3 (
- echo 存在无线网卡设备U3
- netsh wlan add profile filename="C:\RWorker_Test\Pwork_1_2G.xml"
- netsh wlan set profileparameter name="Pwork_1_2G" connectionmode=auto
- )
- if not defined U9 (
- if not defined U3 (
- echo 不存在无线网卡设备
- )
- )
-
- :LSXCE
- ::==========================自动化线体测试过程==========================
- for /f "tokens=2*delims=:^ " %%a in ('echo ^|C:\Intel\10\WIN10ACTIVE\UUDI-KEY\nwinfo_x64.exe --smbios ^|find "UUID:"') do set "UUID0=%%a"
- IF "%UUID0%"=="00020003-0004-0005-0006-000700080009" (C:\Intel\10\WIN10ACTIVE\UUDI-KEY\AMIDEWINx64.exe /SU auto)
- IF "%UUID0%"=="FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF" (C:\Intel\10\WIN10ACTIVE\UUDI-KEY\AMIDEWINx64.exe /SU auto)
- for /f "tokens=2*delims=:^ " %%b in ('echo ^|C:\Intel\10\WIN10ACTIVE\UUDI-KEY\nwinfo_x64.exe --smbios ^|find "UUID:"') do set "UUID1=%%b"
- if not "%UUID0%"=="%UUID1%" (
- echo %UUID0% >C:\Intel\10\UUID.dll
- echo %UUID1% >>C:\Intel\10\UUID.dll
- echo %date% %time% 主板SMBIOS_UUID刷写完成,即将重启系统。
- echo %date% %time% 主板SMBIOS_UUID刷写完成。 >>C:\Intel\10\UUID.dll
- shutdown /r /t 2
- PAUSE
- )
- cd /d C:\RWorker_Test
- Start RWorker.exe
- timeout -t 4 >nul
- Start C:\Intel\10\sinfo.exe
-
- echo,[系统运行状态] >C:\Intel\10\sinfo.ini
-
- set count=0
- set file=run_count.txt
- if exist %file% (
- set /p count=<%file%
- )
- set /a count+=1
- echo %count% > %file%
- if %count% gtr 1 (
- echo,警告:这个脚本已经运行了 %count% 次.
- ) >>C:\Intel\10\sinfo.ini
-
- (
- echo,内存运行频率:!MemorySpeed!
- echo.
- ) >>C:\Intel\10\sinfo.ini
-
- :loop
- timeout -t 2 >nul
- ping -t -n 1 172.17.2.250
- if errorlevel 1 goto loop
- if errorlevel 0 goto yes
- :yes
- cls
-
- if exist C:\DumpStack.log (echo 主机出现过异常重启:C:\DumpStack.log) >>C:\Intel\10\sinfo.ini
- if exist C:\Windows\Minidump\ (
- set count=0
- for /f "tokens=*" %%a in ('dir /b /a - d "C:\Windows\Minidump\*.dmp" 2^>nul') do (
- set /a count+=1
- )
- echo,蓝屏记录!count!个文件如下:
- for /f "tokens=* delims=, " %%b in ('dir /a /s /b C:\Windows\Minidump\*.* ') do echo %%b
- echo.
- ) >>C:\Intel\10\sinfo.ini
-
- :End
- exit
复制代码
|