-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompile.iss
More file actions
95 lines (81 loc) · 3.22 KB
/
compile.iss
File metadata and controls
95 lines (81 loc) · 3.22 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
; Script generated by Inno Setup Script Wizard.
#define MyAppName "Market Trader"
#define MyAppVersion "1.0.1"
#define MyAppPublisher "Mapi Developer"
#define MyAppExeName "MarketTrader.exe"
[Setup]
AppId={{c362c6a4-c152-467b-9f3d-b6f8d659d1cb}}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher}
DefaultDirName={autopf}\{#MyAppName}
DefaultGroupName={#MyAppName}
SetupIconFile=bot\config\app_icon.ico
OutputDir="dist\Output"
OutputBaseFilename=MarketTraderSetup
Compression=lzma
SolidCompression=yes
WizardStyle=modern
; IMPORTANT: This tells Windows to reload environment variables after install
ChangesEnvironment=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "dist\MarketTrader\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "redist\npcap_installer.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall
Source: "redist\tesseract_installer.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
[Run]
Filename: "{tmp}\npcap_installer.exe"; StatusMsg: "Installing Npcap (Required for Packet Sniffing)..."; Flags: waituntilterminated skipifdoesntexist runascurrentuser
Filename: "{tmp}\tesseract_installer.exe"; StatusMsg: "Installing Tesseract OCR (Required for Text Recognition)..."; Flags: waituntilterminated skipifdoesntexist runascurrentuser
[Dirs]
Name: "{app}\config"; Permissions: users-modify
[Code]
const
// This is the default installation path for Tesseract.
// If your installer puts it somewhere else, change this line.
TesseractPath = 'C:\Program Files\Tesseract-OCR';
// Function to append the directory to the PATH variable
procedure AddToPath(PathToAdd: string);
var
RegPath: string;
OldPath: string;
NewPath: string;
begin
// We check the SYSTEM path (requires Admin). Use HKEY_CURRENT_USER if you only want it for the current user.
RegPath := 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment';
// 1. Get the current PATH value
if RegQueryStringValue(HKEY_LOCAL_MACHINE, RegPath, 'Path', OldPath) then
begin
// 2. Check if Tesseract is already in the path to avoid duplicates
if Pos(';' + PathToAdd, ';' + OldPath) = 0 then
begin
// 3. Append the new path
// Handle case where path doesn't end with a semicolon
if (OldPath <> '') and (OldPath[Length(OldPath)] <> ';') then
NewPath := OldPath + ';' + PathToAdd
else
NewPath := OldPath + PathToAdd;
// 4. Write the new path back to the registry
RegWriteExpandStringValue(HKEY_LOCAL_MACHINE, RegPath, 'Path', NewPath);
end;
end;
end;
// Event that triggers after the installation steps are done
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then
begin
// Attempt to add Tesseract to the path
try
AddToPath(TesseractPath);
except
// If it fails (e.g. permissions), we ignore it so setup doesn't crash
Log('Failed to add Tesseract to PATH.');
end;
end;
end;