-
Notifications
You must be signed in to change notification settings - Fork 0
/
updater.nsi
84 lines (72 loc) · 1.7 KB
/
updater.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
!define py2exeOutputDir 'updater'
!define exe 'portable_updater.exe'
!define icon 'E:\Python\python.ico'
!define compressor '/SOLID lzma' ;one of 'zlib', 'bzip2', 'lzma'
!define onlyOneInstance
; - - - - do not edit below this line, normaly - - - -
!ifdef compressor
SetCompressor ${compressor}
!else
SetCompress Off
!endif
Name ${exe}
OutFile ${exe}
SilentInstall silent
!ifdef icon
Icon ${icon}
!endif
Function GetParameters
Push $R0
Push $R1
Push $R2
Push $R3
StrCpy $R2 1
StrLen $R3 $CMDLINE
;Check for quote or space
StrCpy $R0 $CMDLINE $R2
StrCmp $R0 '"' 0 +3
StrCpy $R1 '"'
Goto loop
StrCpy $R1 " "
loop:
IntOp $R2 $R2 + 1
StrCpy $R0 $CMDLINE 1 $R2
StrCmp $R0 $R1 get
StrCmp $R2 $R3 get
Goto loop
get:
IntOp $R2 $R2 + 1
StrCpy $R0 $CMDLINE 1 $R2
StrCmp $R0 " " get
StrCpy $R0 $CMDLINE "" $R2
Pop $R3
Pop $R2
Pop $R1
Exch $R0
FunctionEnd
; - - - - Allow only one installer instance - - - -
!ifdef onlyOneInstance
Function .onInit
System::Call "kernel32::CreateMutexA(i 0, i 0, t '$(^Name)') i .r0 ?e"
Pop $0
StrCmp $0 0 launch
Abort
launch:
FunctionEnd
!endif
; - - - - Allow only one installer instance - - - -
Var Current
Section
; Get directory from which the exe was called
System::Call "kernel32::GetCurrentDirectory(i ${NSIS_MAX_STRLEN}, t .r0)"
StrCpy $Current $0
; Unzip into pluginsdir
InitPluginsDir
SetOutPath '$PLUGINSDIR'
File /r '${py2exeOutputDir}\*.*'
; Set working dir and execute, passing through commandline params
SetOutPath '$Current'
Call GetParameters
ExecWait '"$PLUGINSDIR\${exe}" $R0' $R2
SetErrorLevel $R2
SectionEnd