19 lines
657 B
PowerShell
19 lines
657 B
PowerShell
# Specify the directory containing the scripts
|
|
$scriptDirectory = "C:\Scripts\Tasks\System-Tasks"
|
|
|
|
# Get all Batch scripts in the directory
|
|
$scriptsToRun = Get-ChildItem -Path $scriptDirectory -Filter "*.bat"
|
|
|
|
# Iterate through the script paths and execute each one
|
|
foreach ($script in $scriptsToRun) {
|
|
try {
|
|
# Execute the script
|
|
& "$($script.FullName)"
|
|
|
|
# Add a delay or other actions between scripts if needed
|
|
Write-Host "Script '$script' executed successfully."
|
|
Start-Sleep -Seconds 5 # Adjust the delay as needed
|
|
} catch {
|
|
Write-Warning "Error executing '$script' $($_.Exception.Message)"
|
|
}
|
|
} |