-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTcAutomationInstaller.iss
More file actions
60 lines (54 loc) · 1.57 KB
/
Copy pathTcAutomationInstaller.iss
File metadata and controls
60 lines (54 loc) · 1.57 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
[Setup]
AppName=BCS TwinCAT Automation Tool
AppVersion=1.0.0
DefaultDirName={autopf}\bcs-twincat
DefaultGroupName=BCS Engineering Tools
OutputDir=output
OutputBaseFilename=TcAutomationInstaller
Compression=lzma
SolidCompression=yes
PrivilegesRequired=admin
[Files]
Source: "bin\Release\net9.0\*"; DestDir: "{app}"; Flags: recursesubdirs createallsubdirs ignoreversion
[Icons]
Name: "{group}\TcAutomation (CLI)"; Filename: "{app}\TcAutomation.exe"
Name: "{group}\Uninstall TcAutomation"; Filename: "{uninstallexe}"
[Run]
Filename: "{app}\TcAutomation.exe"; Description: "Run TcAutomation"; Flags: postinstall nowait skipifdoesntexist
[Code]
procedure AddToSystemPath();
var
oldPath, newPath: string;
needsUpdate: Boolean;
begin
// Read the current PATH from the system environment
if RegQueryStringValue(HKEY_LOCAL_MACHINE,
'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', 'Path', oldPath) then
begin
// Avoid duplicating entries
if Pos(ExpandConstant('{app}'), oldPath) = 0 then
begin
newPath := oldPath + ';' + ExpandConstant('{app}');
needsUpdate := True;
end;
end
else
begin
// If registry read fails, initialize with only our path
newPath := ExpandConstant('{app}');
needsUpdate := True;
end;
// Update the registry
if needsUpdate then
begin
RegWriteStringValue(HKEY_LOCAL_MACHINE,
'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', 'Path', newPath);
end;
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then
begin
AddToSystemPath();
end;
end;