|
0)早就解决了word/excel绿色版同时使用的问题,但绿软论坛一直无法注册,直到昨到当再度尝试注册时,才发现注册功能恢复了。很高兴能将我的实现过程与大家分享
1)想法与实现从onegreen下载了绿色word2003和excel2003后,研究了一下,发现wokd/excel只在启动时进行安装和注册的验证,而且我也注意到 word和excel的绿色包中mso.dll可以不拷贝到硬盘的C:\Program Files\Common Files\Microsoft Shared\OFFICE11目录下。于是我开始了对绿色word2003/excel2003的进一步绿化。使用过程中发现这2个程序不可以同时使用,经进一步研究word,excel所写的注册表项,发现之间有很大的不同。一个大胆的猜想映入我的脑海:可不可以运行word或excel后,删除所修改的注册表项,再运行另一个程序。最后用nsis得以实现
2)附件和目录结构 下载附件office2003.rar,解压到任意目录。 压缩包中的目录结构如下
office2003 | Microsoft Excel 2003.exe | Microsoft Word 2003.exe | +---common files | \---Microsoft Shared | \---OFFICE11 | mso.dll (此文件不在压缩包内,请自行拷入) | +---EXCEL2003 | +---app (此目录下文件不在压缩包内,请自行拷入) | | EXCEL.EXE | | GDIPLUS.DLL | | ID_011.DPC | | MSOINTL.dll | | VBAEN32.OLB | | vbe6.dll | | XLINTL32.DLL | | XLLEX.DLL | | | \---portable source | excel2003.nsi | icon.ico | +---word2003 | +---app (此目录下文件不在压缩包内,请自行拷入) | | ID_011.DPC | | MSOHEV.DLL | | MSOINTL.dll | | WINWORD.EXE | | WWINTL.DLL | | | \---portable source | icon.ico | word2003.nsi | \---nsis files registry.nsh (此文件是给想重新编译excel2003.nsi,word2003.nsi registry.dll (备注:这2个文件是重新编译excel2003.nsi,word2003.nsi是所需的 具体使用请参见 http://nsis.sourceforge.net/Registry_plug-in中的Registry.zip里readme.txt 编译时需要下载和安装nsis(http://nsis.sourceforge.net) 安装nsis后,将registry.nsh拷到NSIS\Include下,regsitry.dll拷到NSIS\Plugins下 重新编译后,将在portable source\生成相应的exe文件。请将此生成的exe文件覆盖office2003\相应文件,直接在此目录运行是没用的 ) 3)EXE的说明 在运行Microsoft Excel 2003.exe 或 Microsoft Word 2003.exe过程中,会执行以下动作 31)系统将会先保存以下注册表项 HKCU\software\Microsoft\Office\11.0\ HKLM\software\Microsoft\Office\11.0\ HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion下的键值CommonFilesDir 32)然后写入绿色word/excel所要用的注册表值 33)加winword.exe或excel.exe,并等待word/excel完全加载到内存(这里我偷了个懒,设了个延时5秒。应该是可以用判断winword.exe/excel.exe是否已 在运行进程列表中来做的,而且更合理。但5秒在我的电脑上没有问题---这里所说的问题是会出现“microsoft word没有正确安装”之类的错误。) 34)删除在32)中所写入的注册表值,恢复在31)中保存的注册表值 35)删除在31)中因保存注册表值而在%temp%下所创建的目录和文件
附word2003.nsi
!define PROGRA~ER "abenmao" !define LAUNCHERVERSION "1.0.0.0" !define APPNAME "Microsoft Word 2003" !define SNAME "Microsoft Word 2003" !define EXE "$EXEDIR\word2003\app\winword.exe" !define REGISTRYDIRECTORY "$TEMP\portableoffice\word2003" !define CommonFilesDirReg "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion" !define Office2k3RegHKCU "HKCU\SOFTWARE\Microsoft\Office\11.0" !define Office2k3RegHKLM "HKLM\SOFTWARE\Microsoft\Office\11.0"
;----Includes---- !include "Registry.nsh" ;-----Runtime switches---- CRCCheck on AutoCloseWindow True SilentInstall silent WindowIcon off XPSTYLE on
;-----Set basic information-----
Name "Portable ${APPNAME}" Icon "icon.ico" Caption "Portable ${APPNAME} - ${LAUNCHERVERSION}" OutFile "${SNAME}.exe"
;-----Variables----
;-----Version Information------
LoadLanguageFile "${NSISDIR}\Contrib\Language files\English.nlf"
VIProductVersion "${LAUNCHERVERSION}" VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "Mini Microsoft Word 2003" VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "?${PROGRA~ER} 2006" VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Allows portability of ${APPNAME}." VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${LAUNCHERVERSION}"
;Main program code
SetOverwrite off
Section _RegBackup CreateDirectory "${REGISTRYDIRECTORY}" ${registry::SaveKey} "${Office2k3RegHKCU}" "${REGISTRYDIRECTORY}\o2k3hkcu.reg" "" $0 ${registry::SaveKey} "${Office2k3RegHKLM}" "${REGISTRYDIRECTORY}\o2k3hklm.reg" "" $0 Sleep 1000 ${registry::Read} "${CommonFilesDirReg}" "CommonFilesDir" $0 $1 Sleep 100 ${registry::DeleteKey} "${Office2k3RegHKCU}" $0 ${registry::DeleteKey} "${Office2k3RegHKLM}" $0 Sleep 100 SectionEnd
Section _writereg0 WriteRegDWORD HKLM "SOFTWARE\Microsoft\Office\11.0\Common\InstallRoot" "InstallCount" 0x00000001 WriteRegBin HKLM "SOFTWARE\Microsoft\Office\11.0\Registration\{90110804-6000-11D3-8CFE-0150048383C9}" "DigitalProductID" A40000000300000037333934312D3634302D303030303130362D353739393500720000003132332D313233343500000 00000000000354E1105B8180A8A53AE4C0C2E010000000000BB5D714541460D00000000000000000000000000000000 00000000000000000032343830300000000000000000000000EC11164400020000FA170000000000000000000000000 00000000000000000000000000000000000DE8F3A91 WriteRegBin HKCU "Software\Microsoft\Office\11.0\Common\Licensing" "1EBDE4BC9A514630B5412561FA45CCC5" 01000000270000007B39303131303830342D363030302D313144332D384346452D3031353030343833383343397D00 560000004D006900630072006F0073006F006600740020004F00660066006900630065002000500072006F00660065 007300730069006F006E0061006C002000450064006900740069006F006E00200032003000300033000000 WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion" "CommonFilesDir" "$EXEDIR\Common Files" SectionEnd
Section _runapp Exec "${EXE}" SectionEnd
Section _RegRestore sleep 5000 ${registry::DeleteKey} "${Office2k3RegHKCU}" $0 ${registry::DeleteKey} "${Office2k3RegHKLM}" $0 Sleep 1000 ${registry::Write} "${CommonFilesDirReg}" "CommonFilesDir" $0 "REG_SZ" $R1 ${registry::RestoreKey} "${REGISTRYDIRECTORY}\o2k3hkcu.reg" $0 Sleep 100 ${registry::RestoreKey} "${REGISTRYDIRECTORY}\o2k3hklm.reg" $0 Sleep 100 SectionEnd
Section _CleanUP ${registry::Unload} RMDir /r "${REGISTRYDIRECTORY}" SectionEnd
附excel2003.nsi
!define PROGRA~ER "abenmao" !define LAUNCHERVERSION "1.0.0.0" !define APPNAME "Microsoft Excel 2003" !define SNAME "Microsoft Excel 2003" !define EXE "$EXEDIR\excel2003\app\excel.exe" !define REGISTRYDIRECTORY "$TEMP\portableoffice\excel2003" !define CommonFilesDirReg "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion" !define Office2k3RegHKCU "HKCU\SOFTWARE\Microsoft\Office\11.0" !define Office2k3RegHKLM "HKLM\SOFTWARE\Microsoft\Office\11.0"
;----Includes---- !include "Registry.nsh" ;-----Runtime switches---- CRCCheck on AutoCloseWindow True SilentInstall silent WindowIcon off XPSTYLE on
;-----Set basic information-----
Name "Portable ${APPNAME}" Icon "icon.ico" Caption "Portable ${APPNAME} - ${LAUNCHERVERSION}" OutFile "${SNAME}.exe"
;-----Variables----
;-----Version Information------
LoadLanguageFile "${NSISDIR}\Contrib\Language files\English.nlf"
VIProductVersion "${LAUNCHERVERSION}" VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "Mini Microsoft Excel 2003" VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "?${PROGRA~ER} 2006" VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Allows portability of ${APPNAME}." VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${LAUNCHERVERSION}"
;Main program code
SetOverwrite off
Section _RegBackup CreateDirectory "${REGISTRYDIRECTORY}" ${registry::SaveKey} "${Office2k3RegHKCU}" "${REGISTRYDIRECTORY}\o2k3hkcu.reg" "" $0 ${registry::SaveKey} "${Office2k3RegHKLM}" "${REGISTRYDIRECTORY}\o2k3hklm.reg" "" $0 Sleep 1000 ${registry::Read} "${CommonFilesDirReg}" "CommonFilesDir" $0 $1 Sleep 100 ${registry::DeleteKey} "${Office2k3RegHKCU}" $0 ${registry::DeleteKey} "${Office2k3RegHKLM}" $0 Sleep 100 SectionEnd
Section _writereg0 WriteRegDWORD HKLM "SOFTWARE\Microsoft\Office\11.0\Common\InstallRoot" "InstallCount" 0x00000002 WriteRegBin HKCU "Software\Microsoft\Office\11.0\Common\Licensing" "A2B280D420FB472099F740C09FBCE10A" 02000000270000007B39303131303830342D363030302D313144332D384346452D3031353030343833383343397D005 60000004D006900630072006F0073006F006600740020004F00660066006900630065002000500072006F0066006500 7300730069006F006E0061006C002000450064006900740069006F006E00200032003000300033000000 WriteRegBin HKLM "SOFTWARE\Microsoft\Office\11.0\Registration\{90110804-6000-11D3-8CFE-0150048383C9}" "DigitalProductID" A40000000300000037333934312D3634302D303030303130362D353732393200720000003132332D313233343500000 00000000000354E1105B8180A8A53AE4C0C2E010000000000A29D7545F93E3200000000000000000000000000000000 00000000000000000032343830300000000000000000000000EC11164400020000FA170000000000000000000000000 00000000000000000000000000000000000CCEA134A WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion" "CommonFilesDir" "$EXEDIR\Common Files" SectionEnd
Section _runapp Exec "${EXE}" SectionEnd
Section _RegRestore sleep 5000 ${registry::DeleteKey} "${Office2k3RegHKCU}" $0 ${registry::DeleteKey} "${Office2k3RegHKLM}" $0 Sleep 1000 ${registry::Write} "${CommonFilesDirReg}" "CommonFilesDir" $0 "REG_SZ" $R1 ${registry::RestoreKey} "${REGISTRYDIRECTORY}\o2k3hkcu.reg" $0 Sleep 100 ${registry::RestoreKey} "${REGISTRYDIRECTORY}\o2k3hklm.reg" $0 Sleep 100 SectionEnd
Section _CleanUP ${registry::Unload} RMDir /r "${REGISTRYDIRECTORY}" SectionEnd
|