Last active
August 26, 2022 16:58
-
-
Save biosmanager/7ad461508f80feb16f02d75619c35b95 to your computer and use it in GitHub Desktop.
Scheduled autostart using PowerShell. Programs only start within the specified time frame and not on your days off. Use task scheduler to run at logon. Repository at: https://github.com/biosmanager/scheduled-autostart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param ( | |
$StartTime = '09:00', | |
$EndTime = '18:00', | |
$DaysOff = @('Saturday', 'Sunday') | |
) | |
$StartTimeDate = Get-Date $StartTime | |
$EndTimeDate = Get-Date $EndTime | |
$Date = Get-Date | |
if ($Date.DayOfWeek -notin $DaysOff -and (($Date.TimeOfDay -ge $StartTimeDate.TimeOfDay) -and ($Date.TimeOfDay -le $EndTimeDate.TimeOfDay))) { | |
# Autostart | |
Write-Output 'Another day, another dollar!' | |
Start-Process '<program1>' -RedirectStandardOutput nul | |
Start-Process '<program2>' -RedirectStandardOutput nul | |
} | |
else { | |
Write-Output 'Enjoy your freetime :)' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment