forked from mudclient/paotin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.nsi
172 lines (148 loc) · 5.4 KB
/
install.nsi
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
Name "PaoTin++ for Windows"
OutFile setup.exe
ShowInstDetails show
AllowRootDirInstall true
!include "FileFunc.nsh"
!include "nsDialogs.nsh"
!include "winmessages.nsh"
Page custom SelectDriver
Page instfiles
var dialog
var hctrl
var drive
Function getDrivesCallback
${NSD_CB_AddString} $hctrl "$9"
Push $0
FunctionEnd
Function changeSelect
${NSD_GetText} $hctrl $0
StrCpy $drive $0
FunctionEnd
Function SelectDriver
nsDialogs::Create 1018
Pop $dialog
${NSD_CreateLabel} 0 10u 100% 20u "Select which disk you want to install to:"
Pop $hctrl
${NSD_CreateDropList} 0 30u 100% 80u "Select"
Pop $hctrl
${GetDrives} "HDD" "getDrivesCallback"
StrCpy $drive "C:\"
${NSD_CB_SelectString} $hctrl "$drive"
${NSD_OnChange} $hctrl "changeSelect"
nsDialogs::Show
FunctionEnd
var file
var dir
Section
StrCpy $drive $drive 2
StrCpy $file "$TEMP\settings.json"
FileOpen $R3 $file w
FileWrite $R3 "{$\r$\n"
FileWrite $R3 " $\"profiles$\": $\r$\n"
FileWrite $R3 " {$\r$\n"
FileWrite $R3 " $\"defaults$\": {},$\r$\n"
FileWrite $R3 " $\"list$\": $\r$\n"
FileWrite $R3 " [$\r$\n"
FileWrite $R3 " {$\r$\n"
FileWrite $R3 " $\"commandline$\": $\"$drive\\paotin\\bin\\tt++.exe ids/tintin$\",$\r$\n"
FileWrite $R3 " $\"guid$\": $\"{0b778637-b3ef-410d-b678-3f825e2cdef1}$\",$\r$\n"
FileWrite $R3 " $\"hidden$\": true,$\r$\n"
FileWrite $R3 " $\"name$\": $\"WinTin++$\",$\r$\n"
FileWrite $R3 " $\"startingDirectory$\": $\"$drive\\paotin$\"$\r$\n"
FileWrite $R3 " },$\r$\n"
FileWrite $R3 " {$\r$\n"
FileWrite $R3 " $\"commandline$\": $\"$drive\\paotin\\bin\\tt++.exe ids/paotin$\",$\r$\n"
FileWrite $R3 " $\"guid$\": $\"{0b778637-b3ef-410d-b678-3f825e2cdef2}$\",$\r$\n"
FileWrite $R3 " $\"hidden$\": true,$\r$\n"
FileWrite $R3 " $\"name$\": $\"PaoTin++ for Windows$\",$\r$\n"
FileWrite $R3 " $\"startingDirectory$\": $\"$drive\\paotin$\"$\r$\n"
FileWrite $R3 " },$\r$\n"
FileWrite $R3 " {$\r$\n"
FileWrite $R3 " $\"commandline$\": $\"$drive\\paotin\\bin\\tt++.exe ids/pkuxkx$\",$\r$\n"
FileWrite $R3 " $\"guid$\": $\"{0b778637-b3ef-410d-b678-3f825e2cdef3}$\",$\r$\n"
FileWrite $R3 " $\"hidden$\": false,$\r$\n"
FileWrite $R3 " $\"name$\": $\"\u5317\u5927\u4fa0\u5ba2\u884c$\",$\r$\n"
FileWrite $R3 " $\"startingDirectory$\": $\"$drive\\paotin$\"$\r$\n"
FileWrite $R3 " },$\r$\n"
FileWrite $R3 " {$\r$\n"
FileWrite $R3 " $\"commandline$\": $\"$drive\\paotin\\bin\\tt++.exe ids/thuxyj$\",$\r$\n"
FileWrite $R3 " $\"guid$\": $\"{0b778637-b3ef-410d-b678-3f825e2cdef4}$\",$\r$\n"
FileWrite $R3 " $\"hidden$\": false,$\r$\n"
FileWrite $R3 " $\"name$\": $\"\u6e05\u534e\u897f\u6e38\u8bb0$\",$\r$\n"
FileWrite $R3 " $\"startingDirectory$\": $\"$drive\\paotin$\"$\r$\n"
FileWrite $R3 " }$\r$\n"
FileWrite $R3 " ]$\r$\n"
FileWrite $R3 " }$\r$\n"
FileWrite $R3 "}$\r$\n"
FileClose $R3
StrCpy $dir "$LocalAppData\Microsoft\Windows Terminal\Fragments\PaoTin++"
CreateDirectory "$dir"
CopyFiles /SILENT "$file" "$dir"
RMDir "$LocalAppData\Microsoft\Windows Terminal Preview\Fragments\PaoTin++"
SectionEnd
Section
StrCpy $INSTDIR "$drive\paotin"
StrCpy $OUTDIR "$drive\paotin"
SetOutPath "$INSTDIR"
RMDir "$INSTDIR"
File /r *
StrCpy $file "$drive\paotin\etc\windows.tin"
FileOpen $R3 $file w
FileWrite $R3 "#var gPaoTinPath {$drive/paotin};$\r$\n"
FileWrite $R3 "#var gPaoTinVarPath {$drive/my-paotin};$\r$\n"
FileClose $R3
SectionEnd
!define CreateJunction "!insertmacro CreateJunction"
Function CreateJunction
Exch $4
Exch
Exch $5
Push $1
Push $2
Push $3
Push $6
CreateDirectory "$5"
System::Call "kernel32::CreateFileW(w `$5`, i 0x40000000, i 0, i 0, i 3, i 0x02200000, i 0) i .r6"
${If} $0 = "-1"
StrCpy $0 "0"
RMDir "$5"
goto create_junction_end
${EndIf}
CreateDirectory "$4" ; Windows XP requires that the destination exists
StrCpy $4 "\??\$4"
StrLen $0 $4
IntOp $0 $0 * 2
IntOp $1 $0 + 2
IntOp $2 $1 + 10
IntOp $3 $1 + 18
System::Call "*(i 0xA0000003, &i4 $2, &i2 0, &i2 $0, &i2 $1, &i2 0, &w$1 `$4`, &i2 0)i.r2"
System::Call "kernel32::DeviceIoControl(i r6, i 0x900A4, i r2, i r3, i 0, i 0, *i r4r4, i 0) i.r0"
System::Call "kernel32::CloseHandle(i r6) i.r1"
${If} $0 == "0"
RMDir "$5"
${EndIf}
create_junction_end:
Pop $6
Pop $3
Pop $2
Pop $1
Pop $5
Pop $4
FunctionEnd
!macro CreateJunction Junction Target outVar
Push $0
Push "${Junction}"
Push "${Target}"
Call CreateJunction
StrCpy ${outVar} $0
Pop $0
!macroend
Section
CreateDirectory "$drive\my-paotin"
CreateDirectory "$drive\my-paotin\ids"
CreateDirectory "$drive\my-paotin\etc"
CreateDirectory "$drive\my-paotin\data"
CreateDirectory "$drive\my-paotin\log"
CreateDirectory "$drive\my-paotin\plugins"
${CreateJunction} "$drive\paotin\var" "$drive\my-paotin" $0
SectionEnd