Skip to content

Instantly share code, notes, and snippets.

@biosmanager
Last active August 26, 2022 16:58
Show Gist options
  • Select an option

  • Save biosmanager/7ad461508f80feb16f02d75619c35b95 to your computer and use it in GitHub Desktop.

Select an option

Save biosmanager/7ad461508f80feb16f02d75619c35b95 to your computer and use it in GitHub Desktop.

Revisions

  1. biosmanager revised this gist Aug 26, 2022. No changes.
  2. biosmanager created this gist Jul 31, 2022.
    20 changes: 20 additions & 0 deletions Start-ScheduledAutostart.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    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 :)'
    }