2017-10-13 10 views
0

私がインストールする前にアプリがインストールされているかどうかを確認しようとしています。ここで私はNSISアプリがインストールされていることを確認する

名は実際の名前ですが、あればそれが動作
; Check to see if already installed 
    ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{D9C50188-12D5-4D3E-8F00-682346C2AA5F}" "UninstallString" 
    IfFileExists $R0 +1 NotInstalled 
    MessageBox MB_OK|MB_TOPMOST "App Installed" 

Goto InstallCont2 

を使用していたコードは、名前は次のようにある場合:

{D9C50188-12D5-4D3E-8F00-682346C2AA5F}

それはそれを検出しません。私は別の "または"を入れてみましたが、正しいコードを見つけることができません。

答えて

0

パスのGUIDは重要ではありません。値を読み取れない場合は64ビットの問題かもしれません。あなたはSetRegViewが必要になる場合があります。Process Monitorは助けることができるかもしれませんが、デバッグツールを掘り起こす前に、あなたはそれが何かを読むかどうかを確認するためにReadRegStrMessageBox mb_ok $R0を行う必要があります。

文字列が含まれている場合がありますので、あなただけのUninstallStringから読み込まれた文字列にIfFileExistsを呼び出すことはできません最初に取り除かなければならない引用符やコマンドラインの引数。

よあなたはちょうどパスを得るためにこれを使うことができます:

!macro GetAppPathFromCommandLine output input 
Push '${input}' 
Call GetAppPathFromCommandLine 
Pop ${output} 
!macroend 
Function GetAppPathFromCommandLine 
Exch $0 ; input 
Push $1 ; find 
Push $2 ; start offset 
Push $3 ; temp 
Push $4 ; pos 
StrCpy $1 ' ' 
StrCpy $2 "" 
StrCpy $3 $0 1 
StrCpy $4 -1 
StrCmp $3 '"' 0 +4 
StrCpy $1 $3 
StrCpy $2 1 
StrCpy $4 "" 
loop: 
IntOp $4 $4 + 1 
StrCpy $3 $0 1 $4 
StrCmp $3 "" done 
StrCmp $3 $1 done loop 
done: 
IntOp $4 $4 - $2 
StrCpy $0 $0 $4 $2 
Pop $4 
Pop $3 
Pop $2 
Pop $1 
Exch $0 
FunctionEnd 

Section 
!insertmacro GetAppPathFromCommandLine $0 'c:\foo\bar.exe' 
DetailPrint |$0| 
!insertmacro GetAppPathFromCommandLine $0 '"c:\foo bar\baz.exe"' 
DetailPrint |$0| 
!insertmacro GetAppPathFromCommandLine $0 'c:\foo\bar.exe param1 "pa ra m2" param3' 
DetailPrint |$0| 
!insertmacro GetAppPathFromCommandLine $0 '"c:\foo bar\baz.exe" param1 "pa ra m2" param3' 
DetailPrint |$0| 
SectionEnd 
関連する問題