diff --git a/Patches/Tasks/System_Tasks.ps1 b/Patches/Tasks/System_Tasks.ps1 new file mode 100644 index 0000000..e4b0c55 --- /dev/null +++ b/Patches/Tasks/System_Tasks.ps1 @@ -0,0 +1,19 @@ +# Specify the directory containing the scripts +$scriptDirectory = "C:\Scripts\Login\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)" + } +} \ No newline at end of file diff --git a/Patches/Windows/Add-System-Sched-Task.ps1 b/Patches/Windows/Add-System-Sched-Task.ps1 new file mode 100644 index 0000000..0cfc2a4 --- /dev/null +++ b/Patches/Windows/Add-System-Sched-Task.ps1 @@ -0,0 +1,20 @@ +$newTaskName = "System_Tasks" +$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-File C:\Scripts\Patches\Tasks\System_Tasks.ps1" +$principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -RunLevel Highest +$trigger = New-ScheduledTaskTrigger -AtLogon + +# Register the new task +Register-ScheduledTask -TaskName $newTaskName -Action $action -Principal $principal -Trigger $trigger + +# Get the task and modify settings +$task = Get-ScheduledTask -TaskName $newTaskName +$task.Settings.ExecutionTimeLimit = "PT1H" +$task.Settings.Hidden = $true + +# Update the task in-place +$task | Set-ScheduledTask + +# Output messages +Write-Host "New task '$newTaskName' created with startup trigger." +Write-Host "Task '$newTaskName' will stop after 1 hour of execution." +Write-Host "Task '$newTaskName' is hidden." \ No newline at end of file