-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSSMSPlus-Setup.iss
More file actions
280 lines (249 loc) · 11.5 KB
/
SSMSPlus-Setup.iss
File metadata and controls
280 lines (249 loc) · 11.5 KB
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
[Setup]
AppId={{B8F5E6D2-8C4A-4B5E-9F3A-1D7C8E9B2A4F}
AppName=SSMS Plus
AppVersion=1.2.0
AppVerName=SSMS Plus 1.2.0
AppPublisher=Blake-goofy
AppPublisherURL=https://github.com/Blake-goofy/ssmsplus
AppSupportURL=https://github.com/Blake-goofy/ssmsplus/issues
AppUpdatesURL=https://github.com/Blake-goofy/ssmsplus/releases
DefaultDirName={localappdata}\Programs\SSMS Plus
DisableProgramGroupPage=yes
LicenseFile=
PrivilegesRequired=lowest
OutputDir=installer
OutputBaseFilename=SSMSPlus-Setup
SetupIconFile=ssmsplus_yellow.ico
Compression=lzma
SolidCompression=yes
WizardStyle=modern
UninstallDisplayIcon={app}\SSMSPlus.exe
; Update-related settings
VersionInfoVersion=1.2.0.0
VersionInfoCompany=Blake-goofy
VersionInfoDescription=SSMS Plus - Enhanced SQL Server Management Studio Experience
VersionInfoCopyright=Copyright (C) 2025 Blake-goofy
; Allow updates to overwrite existing installation
AllowNoIcons=yes
CreateUninstallRegKey=yes
UninstallDisplayName=SSMS Plus
DisableFinishedPage=no
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "startup"; Description: "Start SSMS Plus automatically when Windows starts"; GroupDescription: "Startup Options:"
Name: "admininstall"; Description: "Install admin version (allows running as different user)"; GroupDescription: "Admin Installation:"
Name: "adminstartup"; Description: "Start admin version automatically when Windows starts"; GroupDescription: "Admin Installation:"
Name: "ssmslauncher"; Description: "Install SSMS Admin launcher (runs regular SSMS as different user)"; GroupDescription: "Bonus Tools:"
[Files]
Source: "dist\SSMSPlus.exe"; DestDir: "{app}"; Flags: ignoreversion signonce
Source: "ssmsplus_yellow.ico"; DestDir: "{app}"; Flags: ignoreversion
Source: "ssmsplus_red.ico"; DestDir: "{app}"; Flags: ignoreversion
Source: "README.md"; DestDir: "{app}"; Flags: ignoreversion
Source: "SSMS Plus Admin.bat"; DestDir: "{app}"; Flags: ignoreversion; Tasks: admininstall
Source: "SSMS Admin.bat"; DestDir: "{app}"; Flags: ignoreversion; Tasks: ssmslauncher
; Admin installation files - use public location accessible by all users
Source: "dist\SSMSPlus.exe"; DestDir: "C:\Users\Public\SSMS Plus Admin"; Flags: ignoreversion signonce; Tasks: admininstall
Source: "ssmsplus_yellow.ico"; DestDir: "C:\Users\Public\SSMS Plus Admin"; Flags: ignoreversion; Tasks: admininstall
Source: "ssmsplus_red.ico"; DestDir: "C:\Users\Public\SSMS Plus Admin"; Flags: ignoreversion; Tasks: admininstall
Source: "README.md"; DestDir: "C:\Users\Public\SSMS Plus Admin"; Flags: ignoreversion; Tasks: admininstall
Source: "SSMS Plus Admin.bat"; DestDir: "C:\Users\Public\SSMS Plus Admin"; Flags: ignoreversion; Tasks: admininstall
[Icons]
Name: "{autoprograms}\SSMS Plus"; Filename: "{app}\SSMSPlus.exe"; IconFilename: "{app}\ssmsplus_yellow.ico"
Name: "{autodesktop}\SSMS Plus"; Filename: "{app}\SSMSPlus.exe"; IconFilename: "{app}\ssmsplus_yellow.ico"; Tasks: desktopicon
Name: "{userstartup}\SSMS Plus"; Filename: "{app}\SSMSPlus.exe"; Tasks: startup
; Admin installation shortcuts - use user locations instead of common
Name: "{autoprograms}\SSMS Plus Admin"; Filename: "C:\Users\Public\SSMS Plus Admin\SSMSPlus.exe"; IconFilename: "C:\Users\Public\SSMS Plus Admin\ssmsplus_yellow.ico"; Tasks: admininstall
Name: "{autodesktop}\SSMS Plus Admin"; Filename: "C:\Users\Public\SSMS Plus Admin\SSMSPlus.exe"; IconFilename: "C:\Users\Public\SSMS Plus Admin\ssmsplus_yellow.ico"; Tasks: admininstall and adminstartup
Name: "{userstartup}\SSMS Plus Admin"; Filename: "{app}\SSMS Plus Admin.bat"; IconFilename: "{app}\ssmsplus_yellow.ico"; Tasks: admininstall and adminstartup
; SSMS Admin launcher shortcut
Name: "{autoprograms}\SSMS Admin Launcher"; Filename: "{app}\SSMS Admin.bat"; IconFilename: "{app}\ssmsplus_red.ico"; Tasks: ssmslauncher
Name: "{autodesktop}\SSMS Admin Launcher"; Filename: "{app}\SSMS Admin.bat"; IconFilename: "{app}\ssmsplus_red.ico"; Tasks: ssmslauncher
; Add uninstaller to programs menu
Name: "{autoprograms}\Uninstall SSMS Plus"; Filename: "{uninstallexe}"
[Run]
; Always show launch checkbox for regular version
Filename: "{app}\SSMSPlus.exe"; Description: "{cm:LaunchProgram,SSMS Plus}"; Flags: nowait postinstall
; Launch admin version via batch file (with runas) if it was installed - checked by default
Filename: "{app}\SSMS Plus Admin.bat"; Description: "Launch SSMS Plus Admin (as different user)"; Flags: nowait postinstall; Tasks: admininstall
[UninstallRun]
; Stop the application before uninstalling
Filename: "{cmd}"; Parameters: "/C taskkill /F /IM SSMSPlus.exe"; Flags: runhidden; RunOnceId: "StopSSMSPlus"
[UninstallDelete]
; Clean up user settings (optional - you might want to preserve these)
; Type: files; Name: "{userappdata}\SSMSPlus\*"
; Type: dirifempty; Name: "{userappdata}\SSMSPlus"
[Code]
var
UsernameInputPage: TInputQueryWizardPage;
TargetUsername: String;
SSMSExePath: String;
function FindSSMSExe(): String;
var
Paths: array of String;
i: Integer;
begin
Result := '';
// SSMS Plus is built for SSMS 21 - prioritize SSMS 21 paths only
// Older versions may not work correctly due to UI/API changes
SetArrayLength(Paths, 2);
Paths[0] := 'C:\Program Files\Microsoft SQL Server Management Studio 21\Common7\IDE\Ssms.exe';
Paths[1] := 'C:\Program Files (x86)\Microsoft SQL Server Management Studio 21\Common7\IDE\Ssms.exe';
for i := 0 to GetArrayLength(Paths) - 1 do
begin
if FileExists(Paths[i]) then
begin
Result := Paths[i];
Log('Found SSMS 21 at: ' + Result);
break;
end;
end;
if Result = '' then
begin
Log('WARNING: SSMS 21 not found. SSMS Plus is designed for SSMS 21 and may not work correctly with older versions.');
// Fallback to older versions but with warning
SetArrayLength(Paths, 7);
Paths[0] := 'C:\Program Files\Microsoft SQL Server Management Studio 20\Common7\IDE\Ssms.exe';
Paths[1] := 'C:\Program Files (x86)\Microsoft SQL Server Management Studio 20\Common7\IDE\Ssms.exe';
Paths[2] := 'C:\Program Files\Microsoft SQL Server Management Studio 19\Common7\IDE\Ssms.exe';
Paths[3] := 'C:\Program Files (x86)\Microsoft SQL Server Management Studio 19\Common7\IDE\Ssms.exe';
Paths[4] := 'C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE\Ssms.exe';
Paths[5] := 'C:\Program Files (x86)\Microsoft SQL Server\150\Tools\Binn\ManagementStudio\Ssms.exe';
Paths[6] := 'C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio\Ssms.exe';
for i := 0 to GetArrayLength(Paths) - 1 do
begin
if FileExists(Paths[i]) then
begin
Result := Paths[i];
Log('Found older SSMS at: ' + Result + ' (compatibility not guaranteed)');
break;
end;
end;
end;
if Result = '' then
Log('No SSMS installation found in common paths. SSMS Plus requires SSMS 21 for optimal compatibility.');
end;
procedure InitializeWizard();
begin
// Find SSMS executable path
SSMSExePath := FindSSMSExe();
// Create username input page only if admin installation is available
UsernameInputPage := CreateInputQueryPage(wpSelectTasks,
'Admin Installation Settings', 'Specify the username for admin installations',
'Enter the username that will be used for the admin installation batch files. ' +
'This username will be substituted in the batch files for "runas" commands.');
UsernameInputPage.Add('Username:', False);
UsernameInputPage.Values[0] := 'JASCOPRODUCTS\'; // default value with domain prefix
end;
function ShouldSkipPage(PageID: Integer): Boolean;
begin
Result := False;
// Skip username page if admin tasks are not selected
if PageID = UsernameInputPage.ID then
Result := not (WizardIsTaskSelected('admininstall') or WizardIsTaskSelected('ssmslauncher'));
end;
function StringReplace(S, OldPattern, NewPattern: String): String;
var
P: Integer;
begin
Result := S;
P := Pos(OldPattern, Result);
while P > 0 do
begin
Delete(Result, P, Length(OldPattern));
Insert(NewPattern, Result, P);
P := Pos(OldPattern, Result);
end;
end;
function BoolToStr(Value: Boolean): String;
begin
if Value then
Result := 'True'
else
Result := 'False';
end;
function InitializeSetup(): Boolean;
var
ExitCode: Integer;
begin
Result := True;
// Always try to stop any running SSMS Plus process before installation
// This works for both fresh installs and updates
Log('InitializeSetup: Attempting to terminate any running SSMSPlus processes');
Exec('taskkill', '/F /IM SSMSPlus.exe', '', SW_HIDE, ewWaitUntilTerminated, ExitCode);
Log('InitializeSetup: taskkill result = ' + IntToStr(ExitCode));
// Give a moment for the process to fully terminate
Sleep(1000);
end;
function InitializeUninstall(): Boolean;
var
ExitCode: Integer;
begin
Result := True;
// Stop the application before uninstalling
Exec('taskkill', '/F /IM SSMSPlus.exe', '', SW_HIDE, ewWaitUntilTerminated, ExitCode);
// Ask user if they want to keep settings
if MsgBox('Do you want to keep your SSMS Plus settings and configuration?' + #13#13 +
'Choose "Yes" to preserve your settings for future installations.' + #13 +
'Choose "No" to completely remove all SSMS Plus data.',
mbConfirmation, MB_YESNO) = IDNO then
begin
// User wants to remove all data - this would be handled in UninstallDelete section
RegWriteStringValue(HKEY_CURRENT_USER, 'Software\SSMS Plus\Uninstall', 'RemoveAllData', 'true');
end;
end;
procedure CurStepChanged(CurStep: TSetupStep);
var
BatchFile: String;
Lines: TArrayOfString;
i: Integer;
Line: String;
begin
// Simple logging only - let the [Run] section handle launching
Log('CurStepChanged: CurStep = ' + IntToStr(Ord(CurStep)));
if CurStep = ssPostInstall then
begin
// Get the username from the input page
if WizardIsTaskSelected('admininstall') or WizardIsTaskSelected('ssmslauncher') then
TargetUsername := UsernameInputPage.Values[0];
// Process SSMS Plus Admin batch file
if WizardIsTaskSelected('admininstall') then
begin
BatchFile := ExpandConstant('{app}\SSMS Plus Admin.bat');
if LoadStringsFromFile(BatchFile, Lines) then
begin
for i := 0 to GetArrayLength(Lines) - 1 do
begin
Line := Lines[i];
Line := StringReplace(Line, 'username', TargetUsername);
if SSMSExePath <> '' then
Line := StringReplace(Line, 'C:\Program Files (x86)\Microsoft SQL Server Management Studio 19\Common7\IDE\Ssms.exe', SSMSExePath);
Lines[i] := Line;
end;
SaveStringsToFile(BatchFile, Lines, False);
Log('Updated SSMS Plus Admin.bat with username: ' + TargetUsername);
end;
end;
// Process SSMS Admin launcher batch file
if WizardIsTaskSelected('ssmslauncher') then
begin
BatchFile := ExpandConstant('{app}\SSMS Admin.bat');
if LoadStringsFromFile(BatchFile, Lines) then
begin
for i := 0 to GetArrayLength(Lines) - 1 do
begin
Line := Lines[i];
Line := StringReplace(Line, 'username', TargetUsername);
if SSMSExePath <> '' then
Line := StringReplace(Line, 'C:\Program Files (x86)\Microsoft SQL Server Management Studio 19\Common7\IDE\Ssms.exe', SSMSExePath);
Lines[i] := Line;
end;
SaveStringsToFile(BatchFile, Lines, False);
Log('Updated SSMS Admin.bat with username: ' + TargetUsername);
end;
end;
end;
if CurStep = ssDone then
Log('CurStepChanged: Installation complete');
end;