File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path
9
9
. " $scriptPath /scripts/utils/Minimize.ps1" # To get better screenshots we need to minimize the "Administrator" CMD window
10
10
. " $scriptPath /scripts/utils/TimedMessage.ps1"
11
11
. " $scriptPath /scripts/utils/Invoke.ps1" # Function to invoke a script with a timeout
12
+ . " $scriptPath /utils/Screenshot.ps1"
12
13
13
14
# Start the main timer
14
15
$mainTimer = [System.Diagnostics.Stopwatch ]::StartNew()
@@ -111,8 +112,15 @@ foreach ($folder in $folders) {
111
112
$success = Invoke-ScriptWithTimeout - ScriptPath $buildVbaScriptPath - Arguments @ (" ${SourceDir} /${folder} " , " $app " ) - TimeoutSeconds 300
112
113
113
114
if (-not $success ) {
114
- Write-TimedMessage " 🔴 Build-VBA.ps1 execution timed out or failed for ${folder} . Continuing with next file..." - ForegroundColor Yellow
115
- # Optionally add cleanup code here
115
+ Write-TimedMessage " 🔴 Build-VBA.ps1 execution timed out or failed for ${folder} . Continuing with next file..."
116
+
117
+ $screenshotDir = ${SourceDir} + " screenshots/"
118
+ if (-not (Test-Path $screenshotDir )) {
119
+ New-Item - ItemType Directory - Path $screenshotDir - Force | Out-Null
120
+ Write-Host " Created screenshot directory: $screenshotDir "
121
+ }
122
+
123
+ Take- Screenshot - FileName " ${screenshotDir}${app} _{{timestamp}}.png"
116
124
}
117
125
118
126
Write-TimedMessage " Completed processing folder: $folder "
Original file line number Diff line number Diff line change 1
-
2
1
function Invoke-ScriptWithTimeout {
3
2
param (
4
3
[string ]$ScriptPath ,
@@ -7,14 +6,15 @@ function Invoke-ScriptWithTimeout {
7
6
)
8
7
9
8
$job = Start-Job - ScriptBlock {
10
- param ($scriptPath , $args )
11
- & $scriptPath $args
9
+ param ($scriptPath , $arguments )
10
+ # Properly expand the arguments when calling the script
11
+ & $scriptPath @arguments
12
12
} - ArgumentList $ScriptPath , $Arguments
13
13
14
14
$completed = Wait-Job - Job $job - Timeout $TimeoutSeconds
15
15
16
16
if ($completed -eq $null ) {
17
- Write-Host " Script execution timed out after $TimeoutSeconds seconds" - ForegroundColor Red
17
+ Write-Host " 🔴 Script execution timed out after $TimeoutSeconds seconds" - ForegroundColor Red
18
18
Stop-Job - Job $job
19
19
Remove-Job - Job $job - Force
20
20
return $false
You can’t perform that action at this time.
0 commit comments