2017-10-13 3 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를 호출 할 수 없습니다 따옴표 및/또는 명령 줄 인수를 먼저 제거해야합니다.

요 u를 사용하면 다음과 같이 경로를 얻을 수 있습니다.

!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