This repository has been archived by the owner on Sep 7, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExecDos with InputCallBack A-W Auto.iss
296 lines (271 loc) · 12.1 KB
/
ExecDos with InputCallBack A-W Auto.iss
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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
[Setup]
AppName=ExecDos with InputCallBack A-W Auto
AppVersion=1.0
CreateAppDir=no
Uninstallable=no
WizardImageFile=compiler:WizModernImage-IS.bmp
ArchitecturesInstallIn64BitMode=x64
WizardSmallImageFile=compiler:WizModernSmallImage-IS.bmp
DisableWelcomePage=no
PrivilegesRequired=lowest
DisableReadyPage=yes
OutputBaseFilename=ExecDos with InputCallBack A-W Auto
; for InnoSetup 6+:
WizardResizable=yes
WizardStyle=modern
#Include "ExecDosAndCheckRunningA-Wauto.isi"
[Types]
Name: "custom"; Description: "Custom"; Flags: IsCustom;
[Components]
Name: "execute"; Description: "Extract to a ""%tmp%"" and execute from [Files] section via [Code] with output on installing page:";
Name: "execute\a"; Description: "1.cmd (dir %WinDir%)"; Types: custom;
Name: "execute\b"; Description: "2.cmd (ping.exe -w 1000 -l 1 -n 5 0.0.0.0)"; Types: custom;
Name: "execute\c"; Description: "3.cmd (tree /a %WinDir%\System32)"; Types: custom;
Name: "execute\d"; Description: "4.cmd (Please wait.....)"; Types: custom;
[CustomMessages]
StatusMsg=It's executed from script section [Files] via [Code]:
FilesMsg= Executing "%1" via "InputCallBack A or W (auto)"
[Files]
// explanation of use -=> -=> -=> -=> -=> -=> -=> -=> -=> -=> -=> -=> -=> -=> -=> -=> -=> -=> -=> AfterInstall: WriteInputCallBack('cmd-line params', 'StatusMsg message', 'FilesMsg message'); // both last two messages can be empty
DestDir: "{tmp}"; Source: "1.cmd"; Flags: DeleteAfterInstall IgnoreVersion; Components: "execute\a"; AfterInstall: "WriteInputCallBack('""{tmp}\1.cmd""', '{cm:StatusMsg}', '{cm:FilesMsg,{tmp}\1.cmd}')";
DestDir: "{tmp}"; Source: "2.cmd"; Flags: DeleteAfterInstall IgnoreVersion; Components: "execute\b"; AfterInstall: "WriteInputCallBack('""{tmp}\2.cmd""', '{cm:StatusMsg}', '{cm:FilesMsg,{tmp}\2.cmd}')";
DestDir: "{tmp}"; Source: "3.cmd"; Flags: DeleteAfterInstall IgnoreVersion; Components: "execute\c"; AfterInstall: "WriteInputCallBack('""{tmp}\3.cmd""', '{cm:StatusMsg}', '{cm:FilesMsg,{tmp}\3.cmd}')";
DestDir: "{tmp}"; Source: "4.cmd"; Flags: DeleteAfterInstall IgnoreVersion; Components: "execute\d"; AfterInstall: "WriteInputCallBack('""{tmp}\4.cmd""', '{cm:StatusMsg}', '{cm:FilesMsg,{tmp}\4.cmd}')";
[Code]
// for InnoSetup 6.05 Extended Edition -> https://wilenty.wixsite.com/SoftwareByWilenty/inno-setup-xp-ee-script-studio-port
Function InitializeSetup(): Boolean;
begin
With TApplication.Create(nil) do
begin
HintPause := 0;
HintHidePause := 1000 * 30;// 30s
HintShortPause := 0;
Free;
end; // TApplication.Create(nil).
Result := True;
end;
// ^_^
Var
InstallingListBox: TListBox;
Procedure InitializeWizard();
begin
With WizardForm do
begin
InstallingListBox := TListBox.Create(InstallingPage);
With InstallingListBox do
begin
Parent := InstallingPage;
Left := 0;
Top := ProgressGauge.Top + ProgressGauge.Height + ScaleY(5);
Width := InstallingPage.ClientWidth;
Height := InstallingPage.ClientHeight - Top;
Color := clBlack;
With Font do
begin
Color := clLtGray;
Style := Style + [fsBold];
end; // Font.
// for InnoSetup 6+:
Anchors := [akLeft, akTop, akRight, akBottom];
end; // InstallingListBox.
With BackButton do
begin
Left := Left - Width;
ShowHint := True;
end; // BackButton.
With NextButton do
begin
Left := Left - Width;
Width := Width + Width;
ShowHint := True;
end; // NextButton.
end; // WizardForm.
end;
Procedure ListBoxWrite(ListBox: TListBox; Str: String);
begin
ListBox.Items.Insert(0, Str);
AppProcessMessages();
end;
#if Defined Unicode
procedure InstallingCallBack(const OutputW: WideString);
begin
ListBoxWrite(InstallingListBox, OutputW);
end;
#Else
procedure InstallingCallBack(const OutputA: PAnsiChar);
begin
ListBoxWrite(InstallingListBox, OutputA);
end;
#endIf
Function ExpandScript(Str: String): String;
begin
If (Pos('{', Str) > 0) and (Pos('}', Str) > 0) then
Result := ExpandConstant(Str)
else
Result := Str;
end;
#if Defined Unicode
Function GetWindowTextW(hWnd: HWND; lpStringW: String; nMaxCount: Integer): Integer;
External 'GetWindowTextW@User32.dll stdcall';
Function EnumWindowsProc(hwnd: HWND; strParamW: String): BOOL;
Var
WindowTitle: String;
Int: Integer;
begin
Result := True;
Int := 1024;
SetLength(WindowTitle, Int);
Int := GetWindowTextW( HWND, WindowTitle, Int );
If Int = 0 then
exit;
Delete( WindowTitle, Int+1, Length(WindowTitle) );
If Pos( strParamW, WindowTitle ) > 0 then
Result := False;
end;
#Else
Function GetWindowTextA(hWnd: HWND; lpStringA: AnsiString; nMaxCount: Integer): Integer;
External 'GetWindowTextA@User32.dll stdcall';
Function EnumWindowsProc(hwnd: HWND; strParamA: String): BOOL;
Var
WindowTitle: AnsiString;
Int: Integer;
begin
Result := True;
Int := 1024;
SetLength(WindowTitle, Int);
Int := GetWindowTextA( HWND, WindowTitle, Int );
If Int = 0 then
exit;
Delete( WindowTitle, Int+1, Length(WindowTitle) );
If Pos( strParamA, WindowTitle ) > 0 then
Result := False;
end;
#endIf
Var
EnumWindowsProcCallBack: LongWord;
Function EnumWindows(lpEnumFunc: LongWord; sParam: String): BOOL;
External 'EnumWindows@User32.dll stdcall';
Procedure WriteInputCallBack(Params, StatusMsg, FilesMsg: String);
Var
ParamsStr: String;
begin
With WizardForm do
begin
Update;
Repaint;
With InstallingPage do
begin
StatusLabel.Caption := ExpandScript(StatusMsg);
FilenameLabel.Caption := ExpandScript(FilesMsg);
end; // InstallingPage.
end; // WizardForm.
ParamsStr := ExpandScript(Params);
If DosWriteInput( ParamsStr ) then
Repeat
AppProcessMessages();
Sleep(50);
Until EnumWindows( EnumWindowsProcCallBack, ParamsStr );
end;
Var
ProcessID: DWORD;
ProcessExitCode: DWORD;
procedure CurStepChanged(CurStep: TSetupStep);
begin
If CurStep = ssInstall then
begin
EnumWindowsProcCallBack := CreateCallback(@EnumWindowsProc);
ProcessID := ExecDos('cmd.exe', '/k echo off&cls', '', SW_SHOWMINNOACTIVE, @InstallingCallBack, False);
WizardForm.Caption := Format('"cmd.exe" ProcessID: %d', [ProcessID]);
While GetPIDhWND(ProcessID) = 0 do
Sleep(250);
end;
If CurStep = ssPostInstall then
begin
WriteInputCallBack( 'exit /b %ErrorLevel%', 'Exiting the console program...', #9#9'bye, bye, see you next time. ;-)' );
ProcessExitCode := Wait4ProcessExitCode(ProcessID);
end;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
If CurPageID = wpSelectComponents then
WizardForm.NextButton.Caption := FmtMessage( CustomMessage('LaunchProgram'), [''] );
If CurPageID = wpFinished then
begin
MsgBox( Format('ProcessID: %d' + #13#10 + 'ExitCode: %d ($%x)', [ProcessID, ProcessExitCode, ProcessExitCode]), mbInformation, MB_OK );
end;
end;
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "afrikaans"; MessagesFile: "compiler:Languages\Afrikaans.isl"
Name: "albanian"; MessagesFile: "compiler:Languages\Albanian.isl"
Name: "arabic"; MessagesFile: "compiler:Languages\Arabic.islu"
Name: "armenian"; MessagesFile: "compiler:Languages\Armenian.islu"
Name: "asturian"; MessagesFile: "compiler:Languages\Asturian.isl"
Name: "basque"; MessagesFile: "compiler:Languages\Basque.isl"
Name: "belarusian"; MessagesFile: "compiler:Languages\Belarusian.isl"
Name: "bengali"; MessagesFile: "compiler:Languages\Bengali.islu"
Name: "bosnian"; MessagesFile: "compiler:Languages\Bosnian.isl"
Name: "brazilianportuguese"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl"
Name: "bulgarian"; MessagesFile: "compiler:Languages\Bulgarian.islu"
Name: "catalan"; MessagesFile: "compiler:Languages\Catalan.isl"
Name: "chinesesimplified"; MessagesFile: "compiler:Languages\ChineseSimplified.islu"
Name: "chinesetraditional"; MessagesFile: "compiler:Languages\ChineseTraditional.islu"
Name: "corsican"; MessagesFile: "compiler:Languages\Corsican.islu"
Name: "croatian"; MessagesFile: "compiler:Languages\Croatian.islu"
Name: "czech"; MessagesFile: "compiler:Languages\Czech.isl"
Name: "danish"; MessagesFile: "compiler:Languages\Danish.isl"
Name: "dutch"; MessagesFile: "compiler:Languages\Dutch.islu"
Name: "englishbritish"; MessagesFile: "compiler:Languages\EnglishBritish.isl"
Name: "esperanto"; MessagesFile: "compiler:Languages\Esperanto.isl"
Name: "estonian"; MessagesFile: "compiler:Languages\Estonian.isl"
Name: "farsi"; MessagesFile: "compiler:Languages\Farsi.isl"
Name: "finnish"; MessagesFile: "compiler:Languages\Finnish.isl"
Name: "french"; MessagesFile: "compiler:Languages\French.islu"
Name: "galician"; MessagesFile: "compiler:Languages\Galician.islu"
Name: "georgian"; MessagesFile: "compiler:Languages\Georgian.islu"
Name: "german"; MessagesFile: "compiler:Languages\German.islu"
Name: "greek"; MessagesFile: "compiler:Languages\Greek.islu"
Name: "hebrew"; MessagesFile: "compiler:Languages\Hebrew.isl"
Name: "hindi"; MessagesFile: "compiler:Languages\Hindi.islu"
Name: "hungarian"; MessagesFile: "compiler:Languages\Hungarian.isl"
Name: "icelandic"; MessagesFile: "compiler:Languages\Icelandic.islu"
Name: "indonesian"; MessagesFile: "compiler:Languages\Indonesian.islu"
Name: "italian"; MessagesFile: "compiler:Languages\Italian.islu"
Name: "japanese"; MessagesFile: "compiler:Languages\Japanese.isl"
Name: "kazakh"; MessagesFile: "compiler:Languages\Kazakh.islu"
Name: "korean"; MessagesFile: "compiler:Languages\Korean.isl"
Name: "kurdish"; MessagesFile: "compiler:Languages\Kurdish.isl"
Name: "latvian"; MessagesFile: "compiler:Languages\Latvian.isl"
Name: "ligurian"; MessagesFile: "compiler:Languages\Ligurian.isl"
Name: "lithuanian"; MessagesFile: "compiler:Languages\Lithuanian.isl"
Name: "luxemburgish"; MessagesFile: "compiler:Languages\Luxemburgish.isl"
Name: "macedonian"; MessagesFile: "compiler:Languages\Macedonian.isl"
Name: "malaysian"; MessagesFile: "compiler:Languages\Malaysian.isl"
Name: "marathi"; MessagesFile: "compiler:Languages\Marathi.islu"
Name: "mongolian"; MessagesFile: "compiler:Languages\Mongolian.isl"
Name: "montenegrian"; MessagesFile: "compiler:Languages\Montenegrian.isl"
Name: "nepali"; MessagesFile: "compiler:Languages\Nepali.islu"
Name: "norwegian"; MessagesFile: "compiler:Languages\Norwegian.isl"
Name: "norwegiannynorsk"; MessagesFile: "compiler:Languages\NorwegianNynorsk.isl"
Name: "occitan"; MessagesFile: "compiler:Languages\Occitan.isl"
Name: "persian"; MessagesFile: "compiler:Languages\Persian.isl"
Name: "polish"; MessagesFile: "compiler:Languages\Polish.isl"
Name: "portuguese"; MessagesFile: "compiler:Languages\Portuguese.isl"
Name: "romanian"; MessagesFile: "compiler:Languages\Romanian.isl"
Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"
Name: "scottishgaelic"; MessagesFile: "compiler:Languages\ScottishGaelic.islu"
Name: "serbiancyrillic"; MessagesFile: "compiler:Languages\SerbianCyrillic.isl"
Name: "serbianlatin"; MessagesFile: "compiler:Languages\SerbianLatin.isl"
Name: "sinhala"; MessagesFile: "compiler:Languages\Sinhala.islu"
Name: "slovak"; MessagesFile: "compiler:Languages\Slovak.isl"
Name: "slovenian"; MessagesFile: "compiler:Languages\Slovenian.isl"
Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"
Name: "swedish"; MessagesFile: "compiler:Languages\Swedish.isl"
Name: "tatar"; MessagesFile: "compiler:Languages\Tatar.isl"
Name: "thai"; MessagesFile: "compiler:Languages\Thai.isl"
Name: "turkish"; MessagesFile: "compiler:Languages\Turkish.isl"
Name: "ukrainian"; MessagesFile: "compiler:Languages\Ukrainian.isl"
Name: "uyghur"; MessagesFile: "compiler:Languages\Uyghur.islu"
Name: "uzbek"; MessagesFile: "compiler:Languages\Uzbek.isl"
Name: "valencian"; MessagesFile: "compiler:Languages\Valencian.isl"
Name: "vietnamese"; MessagesFile: "compiler:Languages\Vietnamese.islu"