-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathappurl_inst.ahk
152 lines (130 loc) · 5.79 KB
/
appurl_inst.ahk
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
; mpress
#SingleInstance, ignore
#NoTrayIcon
#NoEnv
if not A_IsAdmin
{
params := ""
Run *RunAs %A_ScriptFullPath% /restart %params%, %A_WorkingDir%, UseErrorLevel
Sleep, 2000 ; If the current instance is not replaced after two seconds, it probably failed
MsgBox, 16, Initialization failed, The program could not be started. Please restart the application with administrative rights!
ExitApp, 1 ; Exit current instance
}
Progress, M T A H55 W400 FM10 WM400, , Installing please stand by..., Installing browser plug-in, Tahoma
Progress, 10
host := "PC-HOST" ; Enter host here: Network-name of the machine running the web-interface
Author := "szapp"
Version = 7.0.0.3
Projectname := "Setup Launcher"
FileGetSize, Projectsize, %A_ScriptFullPath%, K
SetRegView 32 ; Wow6432Node\
RegRead, instVersion, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\SetupLauncher, DisplayVersion
RegRead, firefox_inst, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\SetupLauncher, FirefoxIntegrated
if (!firefox_inst)
firefox_inst := ""
if (instVersion >= Version)
{
; Already installed
; MsgBox, Already up-to-date ; Remove
; Allow reinstall!
; GoSub, ToExit
}
Progress, 25
; TODO: Adjust path
path := A_ProgramFiles "\SetupLauncher\appurl.exe"
FileCreateDir, % SubStr(path, 1, InStr(path, "\", 0, 0))
; TODO: Install appurl.exe
FileInstall, appurl.exe, %path%, 1
subkeys := [], keys := [], values := []
subkeys.Insert("appurl")
keys.Insert(""), values.Insert("URL:appurl protocol")
subkeys.Insert("appurl")
keys.Insert("URL Protocol"), values.Insert("")
subkeys.Insert("appurl\DefaultIcon")
keys.Insert(""), values.Insert("appurl.exe")
subkeys.Insert("appurl\Shell")
keys.Insert(""), values.Insert("")
subkeys.Insert("appurl\Shell\Open")
keys.Insert(""), values.Insert("Setup Launcher")
subkeys.Insert("appurl\Shell\Open\Command")
keys.Insert(""), values.Insert("""" path """ ""%1""")
Loop, % subkeys.maxIndex()
{
RegWrite, REG_SZ, HKEY_CLASSES_ROOT, % subkeys[A_Index], % keys[A_Index], % values[A_Index]
if ErrorLevel
{
MsgBox, 16, Registry error, Could not create registry entries properly!
ExitApp, 11
}
}
Progress, 45
; Integrate into firefox
i = 0
While WinExist("ahk_exe firefox.exe")
{
if (i >= 1)
MsgBox, 48, Setup Launcher: Close Mozilla Firefox, To continue with the setup process, please close Mozilla Firefox
WinClose, ahk_exe firefox.exe
i++
Sleep, 7000
Progress, 50
}
d_path := A_AppData "\Mozilla\Firefox\Profiles\"
addto =
(
<RDF:Description RDF:about="urn:scheme:appurl"
NC:value="appurl">
<NC:handlerProp RDF:resource="urn:scheme:handler:appurl"/>
</RDF:Description>
<RDF:Description RDF:about="urn:handler:local:%path%"
NC:prettyName="Setup Launcher"
NC:path="%path%" />
<RDF:Description RDF:about="urn:scheme:handler:appurl"
NC:alwaysAsk="false">
<NC:possibleApplication RDF:resource="urn:handler:local:%path%"/>
<NC:externalApplication RDF:resource="urn:scheme:externalApplication:appurl"/>
</RDF:Description>
<RDF:Description RDF:about="urn:scheme:externalApplication:appurl"
NC:prettyName="Setup Launcher"
NC:path="%path%" />
</RDF:RDF>
)
Progress, 75
Loop, %d_path%*.*, 2, 0
{
if InStr(firefox_inst, A_LoopFileName . "|")
Continue
; %A_LoopFileLongPath%\mimeTypes.rdf
FileCopy, %A_LoopFileLongPath%\mimeTypes.rdf, %A_LoopFileLongPath%\mimeTypes.rdf.BAK, 1
FileRead, Contents, %A_LoopFileLongPath%\mimeTypes.rdf
if ErrorLevel
Continue
if InStr(Contents, "<RDF:Seq RDF:about=""urn:schemes:root"">")
StringReplace, Contents, Contents, <RDF:Seq RDF:about="urn:schemes:root">, <RDF:Seq RDF:about="urn:schemes:root">`n <RDF:li RDF:resource="urn:scheme:appurl"/>
else
addto := "<RDF:Seq RDF:about=""urn:schemes:root"">`n <RDF:li RDF:resource=""urn:scheme:appurl""/>`n </RDF:Seq>" . addto
StringReplace, Contents, Contents, </RDF:RDF>, %addto%
FileDelete, %A_LoopFileLongPath%\mimeTypes.rdf
FileAppend, %Contents%, %A_LoopFileLongPath%\mimeTypes.rdf
firefox_inst .= A_LoopFileName . "|"
}
Progress, 100
; Register for uninstall
RegWrite, REG_SZ, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\SetupLauncher
RegWrite, REG_SZ, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\SetupLauncher, DisplayIcon, "%path%"
RegWrite, REG_SZ, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\SetupLauncher, DisplayName, %Projectname%
RegWrite, REG_SZ, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\SetupLauncher, DisplayVersion, %Version%
RegWrite, REG_SZ, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\SetupLauncher, InstallLocation, % SubStr(path, 1, InStr(path, "\", 0, 0))
RegWrite, REG_DWORD, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\SetupLauncher, NoRepair, 1
RegWrite, REG_DWORD, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\SetupLauncher, NoModify, 1
RegWrite, REG_DWORD, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\SetupLauncher, EstimatedSize, %Projectsize%
RegWrite, REG_SZ, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\SetupLauncher, UninstallString, "%path%" "-uninst"
RegWrite, REG_SZ, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\SetupLauncher, Publisher, %Author%
RegWrite, REG_SZ, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\SetupLauncher, FirefoxIntegrated, %firefox_inst%
FileSetAttrib, -RH, %A_DesktopCommon%\LAN Seeker.lnk
FileDelete, %A_DesktopCommon%\LAN Seeker.lnk
FileCreateShortcut, http://%host%, %A_DesktopCommon%\LAN Seeker.lnk, , , LAN Seeker, %path%, , 1
ToExit:
Run, http://%host%/af/confirmInstall.php?protocol=appurl&version=%Version%
Sleep, 2000
ExitApp