2011-03-15 62 views
0

这是一个令人难以置信的奇怪的错误。安装Chrome扩展程序的NSIS脚本终止Outlook

这是一个NSIS脚本,用于在Google Chrome中安装扩展程序。奇怪的是,如果这是在Outlook 2007运行时在Windows 7上运行的,则会导致Outlook关闭。该错误说“Outlook停止响应”,然后关闭前旋转一分钟。

任何人都可以阐明原因是什么以及如何解决它?

!define VERSION "1.0.0" 
!define EXT_ID "kmffervcdaycdjlksmflkjghksdf" 
!define INSTALL_DIR "$LOCALAPPDATA\Google\Chrome\User Data\Default\Extensions\${EXT_ID}\${VERSION}_0" 
!define P_FILE "$LOCALAPPDATA\Google\Chrome\User Data\Default\Preferences" 

!include "ZipDLL.nsh" 

!include "TextFunc.nsh" 
!insertmacro LineFind 

!include "WordFunc.nsh" 
!insertmacro WordFind 


Name "Chrome Extension Installer" 
OutFile "extension_installer.exe" 
RequestExecutionLevel admin 

Var PMEMORY 
Var SIZE 

Function .onInit 
    SetSilent silent 
FunctionEnd 

Section 
    SetOutPath $TEMP 
    File "extension.crx" 
    File "chrome_preferences.txt" 

    CreateDirectory "${INSTALL_DIR}" 
    ZipDLL::extractall "$TEMP\extension.crx" "${INSTALL_DIR}" 

    StrCpy $0 "${P_FILE}" 
    StrCpy $1 "${P_FILE}" 
    StrCpy $R0 '"settings": {' 
    StrCpy $R1 "$TEMP\chrome_preferences.txt" 
    StrCpy $R2 "0" 
    StrCpy $R3 "0" 
    ${LineFind} "$0" "$1" "1:-2 -1" "LineFindCallback" 
SectionEnd 


Function LineFindCallback 
    StrCmp $PMEMORY '0' end 

    begin: 
    ${WordFind} "$R9" "$R0" "E+1{" $1 
    IfErrors freemem 
    FileWrite $R4 "$1" 

    StrCmp $PMEMORY '' 0 write 
    FileOpen $1 $R1 a 
    FileSeek $1 0 END $SIZE 
    System::Alloc $SIZE 
    Pop $PMEMORY 
    FileSeek $1 0 SET 
    System::Call 'kernel32::ReadFile(i r1, i $PMEMORY, i $SIZE, t.,)' 
    FileClose $1 

    write: 
    IntOp $R3 $R3 + 1 
    System::Call 'kernel32::WriteFile(i R4, i $PMEMORY, i $SIZE, t.,)' 
    ${WordFind} "$R9" "$R0" "+1}" $R9 
    StrCmp $R3 $R2 0 begin 

    freemem: 
    StrCmp $PMEMORY '' end 
    StrCmp $R7 -1 +2 
    StrCmp $R3 $R2 0 end 
    System::Free $PMEMORY 
    StrCpy $PMEMORY 0 

    end: 
    Push $0 
FunctionEnd 
+0

如果你总是希望强制静默安装,你可以使用SilentInstall属性,并不需要for .onInit ... – Anders 2011-03-15 20:29:23

+0

使用$ LOCALAPPDATA混合RequestExecutionLevel管理员不正常,当非管理员用户使用不同的管理员组成员的用户提升时,您将以错误的$ LOCALAPPDATA结束! – Anders 2011-03-15 20:36:29

+0

你可以请分享这个完整的脚本 – 2013-08-10 08:55:41

回答

0

问题原来是ZipDLL。我们现在不使用ZipDLL,而是使用解压缩文件层次结构,问题就消失了。

(由Anders发表的评论似乎都有效,但他们没有真正确定有问题的错误的原因。)

+0

是的,第三方插件崩溃应该是我第二次猜测,但是将无效数据传递给system.dll更可能导致随机问题。你应该报告你的问题@ http://nsis.sourceforge.net/Talk:ZipDLL_plug-in – Anders 2011-03-21 22:16:16

0

我不知道这是不是问题,但你的系统调用写/ ReadFile的错了,尝试...(IR?我$ PMEMORY,我$ SIZE,* I,I 0 )'