Skip to content

Commit d4af51d

Browse files
Jockes update
1 parent 746ea82 commit d4af51d

File tree

5 files changed

+46
-288
lines changed

5 files changed

+46
-288
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,3 @@ input/MttVDD.dll
44
input/MttVDD.inf
55
input/mttvdd.cat
66
input/vdd_settings.xml
7-
8-
**/.claude/settings.local.json
9-
CLAUDE.md

Setup.iss

Lines changed: 30 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
#define MyAppURL "https://vdd.mikethetech.com"
77
#define InstallPath "C:\VirtualDisplayDriver"
88
#define AppId "VirtualDisplayDriver"
9-
#define RegKeyBase "SOFTWARE\MikeTheTech\VirtualDisplayDriver"
10-
#define InstallerTempDir "{localappdata}\VDDInstaller"
119

1210
[Setup]
1311
//no network storage installs
@@ -50,10 +48,8 @@ DisableDirPage=yes
5048
Name: "english"; MessagesFile: "compiler:Default.isl"
5149

5250
[Dirs]
53-
; These directories will be automatically created during installation
54-
; with the specified permissions
55-
Name: "{app}"; Permissions: everyone-full; Flags: uninsalwaysuninstall
56-
Name: "{app}\ControlApp"; Permissions: everyone-full; Flags: uninsalwaysuninstall
51+
Name: "{app}"; Permissions: everyone-full
52+
Name: "{app}\ControlApp"; Permissions: everyone-full
5753

5854
[Files]
5955
Source: "input\MttVDD.dll"; DestDir: "{app}"; Flags: ignoreversion; Components: VDD
@@ -67,9 +63,6 @@ Source: "dependencies\install.bat"; DestDir: "{app}"; Flags: ignoreversion
6763
Source: "dependencies\uninstall.bat"; DestDir: "{app}"; Flags: ignoreversion
6864
Source: "dependencies\fixxml.ps1"; DestDir: "{app}"; Flags: ignoreversion
6965
Source: "input\ControlApp\VDDControl.exe"; DestDir: "{app}\ControlApp"; Components: ControlApp
70-
; Include PowerShell scripts
71-
Source: "input\scripts\*.ps1"; DestDir: "{app}\scripts"; Flags: ignoreversion
72-
Source: "input\scripts\onoff_at_loginout\*"; DestDir: "{app}\scripts\onoff_at_loginout"; Flags: ignoreversion
7366

7467
[Types]
7568
Name: "basic"; Description: "Basic install with driver and control app (recommended)";
@@ -105,7 +98,7 @@ function IsAppAlreadyInstalled(): Boolean;
10598
var
10699
InstalledBy: string;
107100
begin
108-
Result := RegQueryStringValue(HKEY_LOCAL_MACHINE, '{#RegKeyBase}', 'InstalledBy', InstalledBy);
101+
Result := RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\MikeTheTech\VirtualDisplayDriver', 'InstalledBy', InstalledBy);
109102
if Result then
110103
Log('App is already installed by: ' + InstalledBy)
111104
else
@@ -166,148 +159,55 @@ end;
166159
167160
procedure EnsureFilesAndDirectoryExist();
168161
var
169-
Src, Dest, TempDir: String;
170-
FileCopyResult: Boolean;
162+
Src, Dest: String;
171163
begin
172-
// Extract necessary files to temp directory
173-
try
174-
ExtractTemporaryFile('getlist.bat');
175-
except
176-
Log('Warning: Failed to extract getlist.bat to temporary directory');
177-
end;
178-
179-
try
180-
ExtractTemporaryFile('gpulist.txt');
181-
except
182-
Log('Warning: Failed to extract gpulist.txt to temporary directory');
183-
end;
184-
185-
// Create installer temp directory if it doesn't exist
186-
TempDir := ExpandConstant('{#InstallerTempDir}');
187-
if not DirExists(TempDir) then
188-
begin
189-
if not CreateDir(TempDir) then
190-
begin
191-
Log('Error: Failed to create directory: ' + TempDir);
192-
MsgBox('Failed to create the required temporary directory. ' +
193-
'The installation may not complete successfully.', mbError, MB_OK);
194-
Exit;
195-
end;
196-
end;
197-
198-
// Copy the getlist.bat file
164+
ExtractTemporaryFile('getlist.bat');
165+
ExtractTemporaryFile('gpulist.txt');
166+
if not DirExists(ExpandConstant('{localappdata}\VDDInstaller')) then
167+
CreateDir(ExpandConstant('{localappdata}\VDDInstaller'));
168+
Src := ExpandConstant('{tmp}\lfn.exe');
169+
Dest := ExpandConstant('{localappdata}\VDDInstaller\lfn.exe');
170+
if not FileExists(Dest) then
171+
FileCopy(Src, Dest, False);
199172
Src := ExpandConstant('{tmp}\getlist.bat');
200-
Dest := TempDir + '\getlist.bat';
201-
202-
if FileExists(Src) then
203-
begin
204-
if not FileExists(Dest) then
205-
begin
206-
FileCopyResult := FileCopy(Src, Dest, True);
207-
if not FileCopyResult then
208-
Log('Error: Failed to copy ' + Src + ' to ' + Dest);
209-
end;
210-
end
211-
else
212-
Log('Error: Source file not found: ' + Src);
213-
214-
// Copy the gpulist.txt file
173+
Dest := ExpandConstant('{localappdata}\VDDInstaller\getlist.bat');
174+
if not FileExists(Dest) then
175+
FileCopy(Src, Dest, False);
215176
Src := ExpandConstant('{tmp}\gpulist.txt');
216-
Dest := TempDir + '\gpulist.txt';
217-
218-
if FileExists(Src) then
219-
begin
220-
if not FileExists(Dest) then
221-
begin
222-
FileCopyResult := FileCopy(Src, Dest, True);
223-
if not FileCopyResult then
224-
Log('Error: Failed to copy ' + Src + ' to ' + Dest);
225-
end;
226-
end
227-
else
228-
Log('Error: Source file not found: ' + Src);
177+
Dest := ExpandConstant('{localappdata}\VDDInstaller\gpulist.txt');
178+
if not FileExists(Dest) then
179+
FileCopy(Src, Dest, False);
229180
end;
230181
231182
procedure RunGetListAndPopulateGPUComboBox;
232183
var
233184
I, ResultCode: Integer;
234-
ListPath, GetListPath, TempDir: String;
185+
ListPath: String;
235186
begin
236-
// Add default option
237187
GPUComboBox.Items.Add('Best GPU (Auto)');
238188
239-
// Ensure necessary files are available
240189
EnsureFilesAndDirectoryExist();
241-
242-
// Use defined constant for temp directory
243-
TempDir := ExpandConstant('{#InstallerTempDir}');
244-
GetListPath := TempDir + '\getlist.bat';
245-
ListPath := TempDir + '\gpulist.txt';
246-
247-
// Verify getlist.bat exists
248-
if not FileExists(GetListPath) then
190+
ListPath := ExpandConstant('{localappdata}\VDDInstaller\gpulist.txt');
191+
if not FileExists(ExpandConstant('{localappdata}\VDDInstaller\getlist.bat')) then
249192
begin
250-
Log('Error: getlist.bat not found at: ' + GetListPath);
251-
MsgBox('Error: GPU listing utility not found. You can still proceed with installation ' +
252-
'but GPU selection may not work properly.', mbError, MB_OK);
253-
GPUComboBox.ItemIndex := 0;
193+
MsgBox('Error: getlist.bat not found.', mbError, MB_OK);
254194
Exit;
255195
end;
256-
257-
// Execute getlist.bat to gather GPU information
258-
Log('Executing: ' + GetListPath);
259-
if Exec(GetListPath, '', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then
196+
if Exec(ExpandConstant('{localappdata}\VDDInstaller\getlist.bat'), '', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then
260197
begin
261-
Log('getlist.bat executed with result code: ' + IntToStr(ResultCode));
262-
263-
if ResultCode <> 0 then
264-
begin
265-
Log('Warning: getlist.bat exited with non-zero code: ' + IntToStr(ResultCode));
266-
end;
267-
268-
// Load GPU list if available
269198
if FileExists(ListPath) then
270199
begin
271200
GPUList := TStringList.Create;
272201
try
273-
try
274-
GPUList.LoadFromFile(ListPath);
275-
Log('Loaded ' + IntToStr(GPUList.Count) + ' GPUs from list');
276-
277-
for I := 0 to GPUList.Count - 1 do
278-
begin
279-
if Trim(GPUList[I]) <> '' then
280-
begin
281-
GPUComboBox.Items.Add(GPUList[I]);
282-
Log('Added GPU: ' + GPUList[I]);
283-
end;
284-
end;
285-
except
286-
begin
287-
Log('Error loading GPU list');
288-
MsgBox('Error loading GPU list. Default GPU selection will be used.', mbError, MB_OK);
289-
end;
290-
end;
202+
GPUList.LoadFromFile(ListPath);
203+
for I := 0 to GPUList.Count -1 do
204+
GPUComboBox.Items.Add(GPUList[I]);
291205
finally
292-
GPUList.Free;
206+
GPUList.Free;
293207
end;
294-
end
295-
else
296-
begin
297-
Log('Warning: GPU list file not found at: ' + ListPath);
298-
MsgBox('Could not find the GPU list. Default GPU selection will be used.', mbInformation, MB_OK);
299208
end;
300-
end
301-
else
302-
begin
303-
Log('Error: Failed to execute getlist.bat');
304-
MsgBox('Failed to detect GPUs. Default GPU selection will be used.', mbError, MB_OK);
305209
end;
306-
307-
// Ensure a default selection is made
308210
GPUComboBox.ItemIndex := 0;
309-
310-
Log('GPU initialization completed');
311211
end;
312212
313213
function NextButtonClick(CurPageID: Integer): Boolean;
@@ -361,24 +261,8 @@ begin
361261
Result := MonitorsEdit.Text;
362262
end;
363263
364-
function GetInstallDate(Param: string): string;
365-
begin
366-
// Format as yyyy-mm-dd using GetDateTimeString
367-
Result := GetDateTimeString('yyyy-mm-dd', '-', '-');
368-
end;
369-
370264
function MergePar(Param: string): string;
371265
begin
372-
{
373-
Properly quote parameters to handle paths with spaces.
374-
The third parameter (%3 in install.bat) is the installation path.
375-
376-
Jocke's fix in install.bat:
377-
1. For PowerShell: powershell script gets path with special quoting "\"%AppPath%\""
378-
2. For nefconw.exe: Driver installation uses special quoting "\"%AppPath%\MttVDD.inf\""
379-
380-
Both approaches ensure paths with spaces work correctly.
381-
}
382266
Result := Format('%s "%s" "%s"', [
383267
ExpandConstant('{code:GetVDCount}'),
384268
ExpandConstant('{code:GetSelectedGPU}'),
@@ -432,11 +316,9 @@ end;
432316
433317
[Registry]
434318
Root: HKLM; Subkey: "SOFTWARE\MikeTheTech"; Flags: uninsdeletekeyifempty
435-
Root: HKLM; Subkey: "{#RegKeyBase}"; Flags: uninsdeletekeyifempty
436-
Root: HKLM; Subkey: "{#RegKeyBase}"; ValueType: string; ValueName: "VDDPATH"; ValueData: "{app}"; Flags: uninsdeletevalue
437-
Root: HKLM; Subkey: "{#RegKeyBase}"; ValueType: string; ValueName: "InstalledBy"; ValueData: "Installer"; Flags: uninsdeletevalue
438-
Root: HKLM; Subkey: "{#RegKeyBase}"; ValueType: string; ValueName: "InstallDate"; ValueData: "{code:GetInstallDate}"; Flags: uninsdeletevalue
439-
Root: HKLM; Subkey: "{#RegKeyBase}"; ValueType: string; ValueName: "Version"; ValueData: "{#MyAppVersion}"; Flags: uninsdeletevalue
319+
Root: HKLM; Subkey: "SOFTWARE\MikeTheTech\VirtualDisplayDriver"; Flags: uninsdeletekeyifempty
320+
Root: HKLM; Subkey: "SOFTWARE\MikeTheTech\VirtualDisplayDriver"; ValueType: string; ValueName: "VDDPATH"; ValueData: "{app}"; Flags: uninsdeletevalue
321+
Root: HKLM; Subkey: "SOFTWARE\MikeTheTech\VirtualDisplayDriver"; ValueType: string; ValueName: "InstalledBy"; ValueData: "Installer"; Flags: uninsdeletevalue
440322

441323

442324
[Run]

dependencies/fixxml.ps1

Lines changed: 8 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -4,108 +4,17 @@ param (
44
[string]$GPUFN,
55
[string]$InstallDir
66
)
7-
8-
# Remove any extra quotes that might have been added by Jocke's fix in install.bat
9-
$InstallDir = $InstallDir.Trim('"')
10-
Write-Host "Installing to path: $InstallDir"
11-
12-
# Define file paths
137
$file1="$InstallDir\vdd_settings.xml"
148
$file2="$InstallDir\scripts\onoff_at_loginout\psscripts.ini"
159
$file3="$InstallDir\scripts\onoff_at_loginout\vdd_e-li_d-lo.cmd"
1610
$file4="$InstallDir\uninstall.bat"
1711

18-
# Define the default installation path that needs to be replaced
19-
$defaultPath = "C:\VirtualDisplayDriver"
20-
$newPath = "$InstallDir"
21-
22-
# Note: Path handling for spaces is already correct here.
23-
# PowerShell handles paths with spaces properly when variables are properly quoted,
24-
# which we've done throughout this script. Jocke's fix in install.bat complements this.
25-
26-
# Function to safely update file content
27-
function Update-FileContent {
28-
param (
29-
[string]$FilePath,
30-
[string]$OldValue,
31-
[string]$NewValue,
32-
[string]$FileDescription
33-
)
34-
35-
try {
36-
if (-not (Test-Path $FilePath)) {
37-
Write-Warning "File not found: $FilePath ($FileDescription)"
38-
return $false
39-
}
40-
41-
# Create backup with .bak extension
42-
$backupPath = "$FilePath.bak"
43-
Copy-Item -Path $FilePath -Destination $backupPath -Force
44-
45-
# Read file content
46-
$content = Get-Content -Path $FilePath -Raw -ErrorAction Stop
47-
48-
# Replace content
49-
$updatedContent = $content.Replace($OldValue, $NewValue)
50-
51-
# Write back
52-
Set-Content -Path $FilePath -Value $updatedContent -Force -ErrorAction Stop
53-
54-
Write-Host "Updated $FileDescription successfully."
55-
return $true
56-
}
57-
catch {
58-
Write-Error "Error updating $FileDescription: $_"
59-
# Attempt to restore from backup if it exists
60-
if (Test-Path $backupPath) {
61-
Copy-Item -Path $backupPath -Destination $FilePath -Force
62-
Write-Host "Restored $FileDescription from backup."
63-
}
64-
return $false
65-
}
66-
}
67-
68-
# Update XML settings
69-
if (Test-Path $file1) {
70-
Write-Host "Updating VDD settings..."
71-
72-
try {
73-
[xml]$xmlContent = Get-Content -Path $file1 -ErrorAction Stop
74-
75-
# Update XML values using proper XML methods
76-
$monitorNode = $xmlContent.SelectSingleNode("//monitors/count")
77-
if ($monitorNode -ne $null) {
78-
$monitorNode.InnerText = "$NumMon"
79-
}
80-
81-
$gpuNode = $xmlContent.SelectSingleNode("//gpu/friendlyname")
82-
if ($gpuNode -ne $null) {
83-
$gpuNode.InnerText = "$GPUFN"
84-
}
85-
86-
# Save XML with proper formatting
87-
$xmlContent.Save($file1)
88-
Write-Host "Updated VDD settings XML successfully."
89-
}
90-
catch {
91-
Write-Error "Error updating VDD settings XML: $_"
92-
exit 1
93-
}
94-
}
95-
else {
96-
Write-Error "VDD settings file not found: $file1"
97-
exit 1
98-
}
99-
100-
# Update script paths
101-
$pathsUpdated = $true
102-
$pathsUpdated = $pathsUpdated -and (Update-FileContent -FilePath $file2 -OldValue "CmdLine=$defaultPath\scripts\toggle-VDD.ps1" -NewValue "CmdLine=$newPath\scripts\toggle-VDD.ps1" -FileDescription "psscripts.ini")
103-
$pathsUpdated = $pathsUpdated -and (Update-FileContent -FilePath $file3 -OldValue $defaultPath -NewValue $newPath -FileDescription "login/logoff script")
104-
$pathsUpdated = $pathsUpdated -and (Update-FileContent -FilePath $file4 -OldValue $defaultPath -NewValue $newPath -FileDescription "uninstall script")
105-
106-
if (-not $pathsUpdated) {
107-
Write-Warning "Some path updates may have failed. Installation might not work correctly."
108-
}
12+
# Define the replacement
13+
$oldPath = "CmdLine=C:\VirtualDisplayDriver\scripts\toggle-VDD.ps1"
14+
$newPath = "CmdLine=$InstallDir\scripts\toggle-VDD.ps1"
10915

110-
Write-Host "Configuration completed successfully."
111-
exit 0
16+
(Get-Content $file1).replace("<friendlyname>default</friendlyname>","<friendlyname>$GPUFN</friendlyname>")| Set-Content $file1
17+
(Get-Content $file1).replace("<count>1</count>","<count>$NumMon</count>") | Set-Content $file1
18+
(Get-Content $file2).replace($oldPath, $newPath) | Set-Content $file2
19+
(Get-Content $file3).replace("C:\VirtualDisplayDriver", "$InstallDir") | Set-Content $file3
20+
(Get-Content $file4).replace("C:\VirtualDisplayDriver", "$InstallDir") | Set-Content $file4

dependencies/install.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ nefconw.exe --remove-device-node --hardware-id Root\MttVDD --class-guid 4d36e968
77
nefconw.exe --create-device-node --hardware-id Root\MttVDD --class-name Display --class-guid 4D36E968-E325-11CE-BFC1-08002BE10318
88
:: encapsulate that posible space in custum folder
99
nefconw.exe --install-driver --inf-path "\"%AppPath%\MttVDD.inf\""
10-
exit
10+
exit

0 commit comments

Comments
 (0)