本帖最后由 flashercs 于 2022-7-19 12:19 编辑
- @echo off
- setlocal enabledelayedexpansion
- cd /d "%~dp0"
- @REM 文件类型
- set ext=.png .jpg .jpeg .bmp .gif
- @REM 打开程序
- set app=notepad.exe
- for %%A in (%ext%) do call :foo1 %%A
- endlocal
- pause
- exit /b
-
- :foo1
- set alpha=abcdefghijklmnopqrstuvwxyz
- set valueExist=
- for /f "tokens=1-2*" %%A in ('reg query "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\%~1\OpenWithList"^|find /i "REG_SZ"') do (
- if /i "%%~C"=="%app%" (
- set valueExist=1
- goto break
- )
- if /i "%%~A"=="MRUList" (
- set MRUList=%%~C
- ) else (
- set alpha=!alpha:%%~A=!
- )
- )
- :break
- if defined valueExist goto end
- set key=%alpha:~0,1%
- reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\%~1\OpenWithList" /v %key% /t REG_SZ /d "%app%" /f
- reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\%~1\OpenWithList" /v MRUList /t REG_SZ /d "%MRUList%%key%" /f
-
- :end
- exit /b
复制代码
|