用法:复制下列代码,新建一个bat脚本,放置在LibreOfficePortable目录中,双击脚本,按照提示操作。
代码: 全选
@echo off
title Libreoffice关联程序
::pushd %~dp0
mode con cols=77 lines=21
color fc
:list
echo ###########################################
echo # 要关联请程序,请输入1,要删除关联,请输入0 #
echo ###########################################
set /p choice=请输入:
if not defined choice (
goto list
) else (
if "%choice%"=="1" goto install
if "%choice%"=="0" goto remove
)
:install
::关联后缀
assoc .odb=LibreOfficePortable.odb
assoc .odf=LibreOfficePortable.odf
assoc .odg=LibreOfficePortable.odg
assoc .odm=LibreOfficePortable.odm
assoc .odp=LibreOfficePortable.odp
assoc .ods=LibreOfficePortable.ods
assoc .odt=LibreOfficePortable.odt
assoc .otg=LibreOfficePortable.otg
assoc .otp=LibreOfficePortable.otp
assoc .ots=LibreOfficePortable.ots
assoc .ott=LibreOfficePortable.ott
::创建文件类型
ftype LibreOfficePortable.odb="%~dp0LibreOfficeBasePortable.exe -o "%%1"
ftype LibreOfficePortable.odf="%~dp0LibreOfficeMathPortable.exe" -o "%%1"
ftype LibreOfficePortable.odg="%~dp0LibreOfficeDrawPortable.exe" -o "%%1"
ftype LibreOfficePortable.odm="%~dp0LibreOfficeWriterPortable.exe" -o "%%1"
ftype LibreOfficePortable.odp="%~dp0LibreOfficeImpressPortable.exe" -o "%%1"
ftype LibreOfficePortable.ods="%~dp0LibreOfficeCalcPortable.exe" -o "%%1"
ftype LibreOfficePortable.odt="%~dp0LibreOfficeWriterPortable.exe" -o "%%1"
ftype LibreOfficePortable.otg="%~dp0LibreOfficeDrawPortable.exe" -o "%%1"
ftype LibreOfficePortable.otp="%~dp0LibreOfficeImpressPortable.exe" -o "%%1"
ftype LibreOfficePortable.ots="%~dp0LibreOfficeCalcPortable.exe" -o "%%1"
ftype LibreOfficePortable.ott="%~dp0LibreOfficeWriterPortable.exe" -o "%%1"
::文件图标
reg add "HKEY_CLASSES_ROOT\LibreOfficePortable.odb\DefaultIcon" /ve /t REG_SZ /d "%~dp0App\libreoffice\program\soffice.bin,11"
reg add "HKEY_CLASSES_ROOT\LibreOfficePortable.odf\DefaultIcon" /ve /t REG_SZ /d "%~dp0App\libreoffice\program\soffice.bin,12"
reg add "HKEY_CLASSES_ROOT\LibreOfficePortable.odg\DefaultIcon" /ve /t REG_SZ /d "%~dp0App\libreoffice\program\soffice.bin,5"
reg add "HKEY_CLASSES_ROOT\LibreOfficePortable.odm\DefaultIcon" /ve /t REG_SZ /d "%~dp0App\libreoffice\program\soffice.bin,9"
reg add "HKEY_CLASSES_ROOT\LibreOfficePortable.odp\DefaultIcon" /ve /t REG_SZ /d "%~dp0App\libreoffice\program\soffice.bin,7"
reg add "HKEY_CLASSES_ROOT\LibreOfficePortable.ods\DefaultIcon" /ve /t REG_SZ /d "%~dp0App\libreoffice\program\soffice.bin,3"
reg add "HKEY_CLASSES_ROOT\LibreOfficePortable.odt\DefaultIcon" /ve /t REG_SZ /d "%~dp0App\libreoffice\program\soffice.bin,1"
reg add "HKEY_CLASSES_ROOT\LibreOfficePortable.otg\DefaultIcon" /ve /t REG_SZ /d "%~dp0App\libreoffice\program\soffice.bin,6"
reg add "HKEY_CLASSES_ROOT\LibreOfficePortable.otp\DefaultIcon" /ve /t REG_SZ /d "%~dp0App\libreoffice\program\soffice.bin,8"
reg add "HKEY_CLASSES_ROOT\LibreOfficePortable.ots\DefaultIcon" /ve /t REG_SZ /d "%~dp0App\libreoffice\program\soffice.bin,4"
reg add "HKEY_CLASSES_ROOT\LibreOfficePortable.ott\DefaultIcon" /ve /t REG_SZ /d "%~dp0App\libreoffice\program\soffice.bin,2"
#退出
exit
:remove
::删除关联
assoc .odb=
assoc .odf=
assoc .odg=
assoc .odm=
assoc .odp=
assoc .ods=
assoc .odt=
assoc .otg=
assoc .otp=
assoc .ots=
assoc .ott=
::删除文件类型
reg delete "HKEY_CLASSES_ROOT\LibreOfficePortable.odb" /f
reg delete "HKEY_CLASSES_ROOT\LibreOfficePortable.odf" /f
reg delete "HKEY_CLASSES_ROOT\LibreOfficePortable.odg" /f
reg delete "HKEY_CLASSES_ROOT\LibreOfficePortable.odm" /f
reg delete "HKEY_CLASSES_ROOT\LibreOfficePortable.odp" /f
reg delete "HKEY_CLASSES_ROOT\LibreOfficePortable.ods" /f
reg delete "HKEY_CLASSES_ROOT\LibreOfficePortable.odt" /f
reg delete "HKEY_CLASSES_ROOT\LibreOfficePortable.otg" /f
reg delete "HKEY_CLASSES_ROOT\LibreOfficePortable.otp" /f
reg delete "HKEY_CLASSES_ROOT\LibreOfficePortable.ots" /f
reg delete "HKEY_CLASSES_ROOT\LibreOfficePortable.ott" /f
::重新加载外壳
taskkill /f /im explorer.exe
start explorer