-
Notifications
You must be signed in to change notification settings - Fork 0
/
SafeRunAutoScheduler.ps1
39 lines (30 loc) · 1.38 KB
/
SafeRunAutoScheduler.ps1
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
<#
.SYNOPSIS
This script sets up and runs the AutoScheduler with a specified interval.
.DESCRIPTION
The script performs the following tasks:
1. Runs a script to kill any existing AutoScheduler process.
2. Updates the interval in the AutoScheduler.vbs script.
3. Starts the AutoScheduler.vbs script with the specified interval.
.PARAMETER interval
The interval in seconds at which the AutoScheduler should run. Default is 3600 seconds (1 hour).
.EXAMPLE
.\SafeRunAutoScheduler.ps1 -interval 1800
This example sets the interval to 1800 seconds (30 minutes) and runs the AutoScheduler.
.NOTES
The script assumes that the KillAutoScheduler.ps1 and AutoScheduler.vbs scripts are located in the same directory as this script.
#>
param(
[string]$interval = "3600" # Default interval is 1 hour
)
# Setup ps1 script path
$killAutoSchedulerScript = "$PSScriptRoot\KillAutoScheduler.ps1"
# Run the script to kill the AutoScheduler process
& $killAutoSchedulerScript
$vsbFile = "$PSScriptRoot\AutoScheduler.vbs"
# Replace the interval in the AutoScheduler.vbs script
(Get-Content $vsbFile) | ForEach-Object { $_ -replace "interval = \d+", "interval = $interval" } | Set-Content $vsbFile
Write-Host "Interval is set to $interval seconds."
# Run the AutoBreakTheWall.vbs script
Start-Process -FilePath $vsbFile -WindowStyle Hidden
Write-Host "AutoScheduler.vbs is running."