forked from n-air-app/n-air-app
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstaller.nsh
106 lines (84 loc) · 3.64 KB
/
installer.nsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
!macro registerProtocol Protocol
DetailPrint "Register ${Protocol} URI Handler"
DeleteRegKey HKCU "Software\Classes\${Protocol}"
WriteRegStr HKCU "Software\Classes\${Protocol}" "" "URL:${Protocol}"
WriteRegStr HKCU "Software\Classes\${Protocol}" "URL Protocol" ""
WriteRegStr HKCU "Software\Classes\${Protocol}\shell" "" ""
WriteRegStr HKCU "Software\Classes\${Protocol}\shell\Open" "" ""
WriteRegStr HKCU "Software\Classes\${Protocol}\shell\Open\command" "" '"$appExe" "%1"'
!macroend
!macro unregisterProtocol Protocol
DeleteRegKey HKCU "Software\Classes\${Protocol}"
!macroend
# English
LangString failed_install 1033 "WARNING: N Air was unable to install the latest Visual C++ Redistributable package from Microsoft."
LangString require_restart 1033 "You must restart your computer to complete the installation."
LangString failed_download 1033 "WARNING: N Air was unable to download the latest Visual C++ Redistributable package from Microsoft."
# Japanese
LangString failed_install 1041 "警告: Microsoft の最新の Visual C++ 再頒布可能パッケージのインストールができませんでした。"
LangString require_restart 1041 "インストールを完了するには、コンピューターを再起動してください。"
LangString failed_download 1041 "警告: Microsoft から最新の Visual C++ 再頒布可能パッケージをダウンロードできませんでした。"
!macro customInstall
NSISdl::download https://aka.ms/vs/17/release/vc_redist.x64.exe "$INSTDIR\vc_redist.x64.exe"
${If} ${FileExists} `$INSTDIR\vc_redist.x64.exe`
ExecWait '$INSTDIR\vc_redist.x64.exe /passive /norestart' $1
${If} $1 != '0'
${If} $1 != '3010'
MessageBox MB_OK|MB_ICONEXCLAMATION "$(failed_install)"
${EndIf}
${EndIf}
# ${If} $1 == '3010'
# MessageBox MB_OK|MB_ICONEXCLAMATION "$(require_restart)"
# ${EndIf}
${Else}
MessageBox MB_OK|MB_ICONEXCLAMATION "$(failed_download)"
${EndIf}
FileOpen $0 "$INSTDIR\installername" w
FileWrite $0 $EXEFILE
FileClose $0
!insertMacro registerProtocol "n-air-app"
!macroend
!include "MUI2.nsh"
!include "nsDialogs.nsh"
Var Dialog
Var CheckBox
Var Label
var /GLOBAL CheckBoxState
!macro customUninstallPage
UninstPage custom un.removeAppDataPage un.removeAppDataPageLeave
Function un.removeAppDataPage
nsDialogs::Create 1018
Pop $Dialog
; 既にアンインストールは完了してしまっているためキャンセルボタンは無効化する
GetDlgItem $0 $HWNDPARENT 2
EnableWindow $0 0
${NSD_CreateCheckbox} 10u 40u 200u 12u "アプリデータを削除する"
Pop $CheckBox
${NSD_SetState} $CheckBox 0
${If} $CheckBoxState == ${BST_CHECKED}
${NSD_SetState} $CheckBox ${BST_CHECKED}
${EndIf}
${NSD_CreateLabel} 20u 54u 190u 36u "N Air上で設定したデータを完全に削除します。$\nアプリが起動できなくなってしまった場合は、アプリデータの削除をした上で再インストールをお試しください。"
Pop $Label
nsDialogs::Show
FunctionEnd
Function un.removeAppDataPageLeave
${NSD_GetState} $CheckBox $CheckBoxState
${If} $CheckBoxState == ${BST_CHECKED}
; change APPDATA ProgramData to Roming
SetShellVarContext current
RMDir /r "$APPDATA\${APP_PACKAGE_NAME}"
${EndIf}
FunctionEnd
; MUI_UNPAGE_FINISHの戻るボタンを無効化する
!define MUI_PAGE_CUSTOMFUNCTION_SHOW un.disableBack
Function un.disableBack
Push $0
GetDlgItem $0 $HWNDPARENT 3
EnableWindow $0 0
Pop $0
FunctionEnd
!macroend
!macro customUninstall
!insertMacro unregisterProtocol "n-air-app"
!macroend