こんにちは私は古いインストールスクリプトをリファクタリングして、UACプラグインが作成する問題に取り掛かります。 !insertmacro Init "installer"
のため、.onInit
が2回実行されます。 !insertmacro Init "uninstaller"
とun.onInit
の機能も同じです。NSISインストーラ.onInitとun.onInitがUACのために2回実行する
このため、インストーラとアンインストーラは2回実行されますが、これは必要な動作ではありません。例えばC:/
ドライブに触れるときには必要ですが、外側のプロセスでもインストーラが実行されます。I have read that the UAC creates an inner process with elevated permissions
インストールスクリプトがかなり長いため、私は.onInit
機能を貼り付けます。 .nsi
スクリプト全体はhereです。
!insertmacro
の行をコメントアウトすると、.onInit
関数が一度実行されますが、インストーラはもう実行されません。では、インストーラとアンインストーラを一度しか実行せず、正しい(管理者)権限で実行するにはどうすればよいですか?
私はどんな提案を感謝したり答え:)
Function .onInit
MessageBox MB_OK "In .onInit"
SetShellVarContext all
!insertmacro Init "installer"
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "Tribler") i .r1 ?e'
Pop $R0
StrCmp $R0 0 checkinst
MessageBox MB_OK "The installer is already running."
Abort
checkinst:
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}" "UninstallString"
StrCmp $R0 "" done
IfFileExists $R0 showuninstdialog done
showuninstdialog:
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "${PRODUCT} is already installed. $\n$\nClick `OK` to remove the previous version or `Cancel` to cancel this upgrade." /SD IDCANCEL IDOK uninst
Abort
uninst:
ClearErrors
; Laurens (2016-03-29): Retrieve the uninstallString stored in the register. Do NOT use $INSTDIR as this points to the current $INSTDIR var of the INSTALLER,
; which is the default location at this point.
ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}" "UninstallString"
MessageBox MB_OK "$R0"
ExecWait '"$R0"' ;Do not copy the uninstaller to a temp file
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}" "UninstallString"
StrCmp $R0 "" done
Abort
done:
FunctionEnd
ここに貼り付けた.onInitコードは、リンク先のコードと一致しません!リンク先のコードには明確な問題があります。ここに貼り付けたコードに自分自身をテストすることなく問題があるかどうかは実際には分かりませんが、テストするコードを明確にするまではこれを行いません。使用されるNSIS/UACプラグイン/ Windowsバージョンについてのいくつかの情報を持っているといいですね。 – Anders
@アンダー私はこれをタイプしながらいくつかのことを押して試しています。ごめんなさい。現在実行中のコードのリンク内のコードを考えてみましょう。また、私はWindows 2008の64ビットサーバー上に構築しており、Windowsのマシンでも64ビットのインストール手順をテストしています。 – Gooey
@アンダーズ私は実験的な変更のいくつかを取り消し、それらを押した。人々がそれを見ているときにそれが実際に混乱しているので、私は今それを押してはいけません。 – Gooey