A couple of days ago, I wrote a simple piece of code to view the paths of programs that start automatically at boot . Regardless of whether the query is comprehensive or not, during testing, I encountered a very headache-inducing problem:
If the path of a program that starts automatically at boot contains N Chinese characters (the character type in the registry is REG_SZ, and other types of characters haven't been tested yet), then the last N characters of this path (one Chinese character occupies two character positions) will be ignored. It might be related to the fact that the internal code of Chinese is double-byte, and I can't specifically explain the reason. For example, create a REG_SZ string test under HKEY_Local_Machine\Software\Microsoft\Windows\CurrentVersion\Run with the value c:\program files\测试\test.exe. Then, after executing the code in , the line where test is located shows c:\program files\测试\test.e; if the above value is c:\program files\测试\再次测试.exe, the result will show c:\program files\测试\再次测.
How should this problem be solved?
1、
[ Last edited by namejm on 2006-8-1 at 15:21 ]
If the path of a program that starts automatically at boot contains N Chinese characters (the character type in the registry is REG_SZ, and other types of characters haven't been tested yet), then the last N characters of this path (one Chinese character occupies two character positions) will be ignored. It might be related to the fact that the internal code of Chinese is double-byte, and I can't specifically explain the reason. For example, create a REG_SZ string test under HKEY_Local_Machine\Software\Microsoft\Windows\CurrentVersion\Run with the value c:\program files\测试\test.exe. Then, after executing the code in , the line where test is located shows c:\program files\测试\test.e; if the above value is c:\program files\测试\再次测试.exe, the result will show c:\program files\测试\再次测.
How should this problem be solved?
1、
@echo off
setlocal enabledelayedexpansion
echo.
echo The programs that start automatically at boot are:
echo.
for /f "skip=4 tokens=1* delims=:" %%i in ('reg query HKLM\Software\Microsoft\Windows\CurrentVersion\Run') do (
set str=%%i
set var=%%j
set "var=!var:"=!"
if not "!var:~-1!"=="=" echo !str:~-1!:!var!
)
pause>nul
[ Last edited by namejm on 2006-8-1 at 15:21 ]
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
考虑问题复杂化,解决问题简洁化。
