PoshCode Logo PowerShell Code Repository

Set-WinSchedule by Tome Tanasovski 23 months ago (modification of post by Tome Tanasovski view diff)
View followups from Tome Tanasovski | diff | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/1694"></script>download | new post

Set-Computer gives a GUI to select a schedule and schedules a task using schtasks. This is a beta. There are still a lot of features to implement. Please read through the synopsis->Description to see the list of features that I hope to get in a final release.

  1. # Set-WinSchedule
  2. # Written by Tome Tanasovski
  3. # http://powertoe.wordpress.com
  4. # version 1.0
  5. # Created March 2010
  6. #
  7. # Please read through the synopsis->Description to see the list of features that I hope to get
  8. # in a final release.  If you choose to work on any of the issues by all means, but please contact
  9. # me to let me know so that no effort is duplicated
  10.  
  11. # Winform Assemblies
  12. [reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null
  13. [reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
  14.  
  15. function Set-WinSchedule {
  16.     <#
  17.       .Synopsis
  18.         Creates a winform to select a schedule and creates a scheduled task
  19.        .Description
  20.         Set-Computer gives a GUI to select a schedule and schedules a task using schtasks
  21.         This is a beta.  There are still a lot of features to implement:
  22.             Need to have more scheduling options.  I expect to have all options available in a recurring outlook calendar item
  23.             Need to have methods for scheduling with all 3 providers: schtasks, wmi, and at.  Currently it only uses schtasks
  24.             Need to design the return object properties:
  25.                 Should contain the text paths for each provider type
  26.                 Should contain a date/time for start time
  27.             Need to provide a method to overwrite an existing task if it has the same name and the user confirms that it is ok to overwrite.  Should also provide
  28.             a -force parameter for this option.
  29.             Need to ensure that files piped from get-item will be scheduled
  30.             Need a parameter to override ok box at the end
  31.        .Example
  32.         Set-Schedule c:\windows\notepad.exe    
  33.        .Parameter TaskRun
  34.         The name of the command to be scheduled
  35.        .Parameter ScheduleName
  36.         The name that the scheduled task will be given.  
  37.        .Notes
  38.         NAME:  Set-Schedule
  39.         AUTHOR: Tome Tanasovski
  40.         LASTEDIT: 3/11/2010
  41.         KEYWORDS:
  42.        .Link
  43.          http://powertoe.wordpress.com
  44.      #>
  45.     param(
  46.         [Parameter(Position=1,Mandatory=$true)]
  47.         [string] $taskrun,
  48.         [Parameter(Position=2,Mandatory=$true)]
  49.         [string] $taskname
  50.     )
  51.     $command = "& schtasks.exe /query /tn $taskname"
  52.     $job = start-job $ExecutionContext.InvokeCommand.NewScriptBlock($command)
  53.     Wait-Job $job
  54.     if ($job.ChildJobs[0].output -ne "") {  
  55.         [System.windows.forms.messagebox]::show("A task named $taskname already exists.  You must delete this task before you can use the name.")
  56.         return        
  57.     }
  58.    
  59.    
  60.     $SchedulePickerForm = New-Object System.Windows.Forms.Form
  61.     $comboTime = New-Object System.Windows.Forms.ComboBox
  62.     $label4 = New-Object System.Windows.Forms.Label
  63.     $buttonCancel = New-Object System.Windows.Forms.Button
  64.     $buttonOK = New-Object System.Windows.Forms.Button
  65.     $group = New-Object System.Windows.Forms.GroupBox
  66.     $checkSaturday = New-Object System.Windows.Forms.CheckBox
  67.     $checkFriday = New-Object System.Windows.Forms.CheckBox
  68.     $checkThursday = New-Object System.Windows.Forms.CheckBox
  69.     $checkWednesday = New-Object System.Windows.Forms.CheckBox
  70.     $checkTuesday = New-Object System.Windows.Forms.CheckBox
  71.     $checkMonday = New-Object System.Windows.Forms.CheckBox
  72.     $checkSunday = New-Object System.Windows.Forms.CheckBox
  73.     $labelDays = New-Object System.Windows.Forms.Label
  74.     $labelHours = New-Object System.Windows.Forms.Label
  75.     $boxHourlyDaily = New-Object System.Windows.Forms.TextBox
  76.     $labelEvery = New-Object System.Windows.Forms.Label
  77.     $radioHourly = New-Object System.Windows.Forms.RadioButton
  78.     $radioWeekly = New-Object System.Windows.Forms.RadioButton
  79.     $radioDaily = New-Object System.Windows.Forms.RadioButton
  80.     $InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
  81.     $checkboxes = ($checkMonday,$checkTuesday,$checkWednesday,$checkThursday,$checkFriday,$checkSaturday,$checkSunday)
  82.  
  83.     function VisibleInvisibleCheckBoxes {
  84.         Write-Host $checkboxes
  85.         $checkboxes |foreach {$_.visible = -not $_.visible}
  86.     }
  87.     # Events
  88.     $handler_radioButtonChanged = {    
  89.         switch ($true) {
  90.             ($radioHourly.Checked) {
  91.                 $labelHours.Visible = $true
  92.                 $labelDays.Visible = $false
  93.                 $boxHourlyDaily.Visible = $true
  94.                 $checkboxes |foreach {$_.visible = $false}
  95.             }
  96.             ($radioDaily.Checked) {
  97.                 $labelHours.Visible = $false
  98.                 $labelDays.Visible = $true
  99.                 $boxHourlyDaily.Visible = $true
  100.                 $checkboxes |foreach {$_.visible = $false}
  101.             }
  102.             ($radioWeekly.Checked) {
  103.                 $labelHours.Visible = $false
  104.                 $labelDays.Visible = $false
  105.                 $boxHourlyDaily.Visible = $false
  106.                 $checkboxes |foreach {$_.visible = $true}
  107.             }
  108.         }
  109.     }
  110.  
  111.     $buttonCancel_OnClick = {
  112.         $SchedulePickerForm.Close()
  113.         return $null
  114.     }
  115.  
  116.     $buttonOK_OnClick = {
  117.         $doit = $false
  118.         switch ($true) {
  119.             ($radioHourly.Checked -or $radioDaily.Checked) {
  120.                 try {
  121.                     $recurrence = [Convert]::ToInt32($boxHourlyDaily.Text)
  122.                     if ($recurrence -gt 0) {
  123.                         try {
  124.                             switch ($true) {
  125.                                 ($radiohourly.checked) {
  126.                                     if ($recurence -gt 23) {
  127.                                         [System.windows.forms.messagebox]::show("Hourly recurrence must be 1-23 hours")
  128.                                         $boxHourlyDaily.Focus()
  129.                                     }
  130.                                     else {                                
  131.                                         & schtasks /create /tn $taskname /tr "$taskrun" /sc hourly /mo $boxHourlyDaily.Text /st $comboTime.Text /f
  132.                                         [System.Windows.Forms.Messagebox]::show("Task has been scheduled")
  133.                                         $SchedulePickerForm.Close()                                                                        
  134.                                     }
  135.                                 }
  136.                                 ($radioDaily.checked) {
  137.                                     if ($recurence -gt 365) {
  138.                                         [System.windows.forms.messagebox]::show("Hourly recurrence must be 1-365 hours")
  139.                                         $boxhourlydaily.focus()
  140.                                     }
  141.                                     else {
  142.                                         & schtasks /create /tn $taskname /tr $taskrun /sc daily /mo $boxHourlyDaily.Text /st $comboTime.Text /f
  143.                                         $SchedulePickerForm.Close()                                
  144.                                     }
  145.                                 }
  146.                             }                            
  147.                         }
  148.                         catch {
  149.                             [System.windows.forms.messagebox]::show($error[0])
  150.                         }
  151.                     }
  152.                     else {
  153.                         [System.windows.forms.messagebox]::show("Recurrence must be greater than 0")
  154.                         $boxHourlyDaily.Focus()
  155.                     }
  156.                 }
  157.                 catch {
  158.                     [System.windows.forms.messagebox]::show("You must enter a valid integer recurrence")
  159.                     $boxHourlyDaily.Focus()
  160.                 }
  161.             }
  162.             ($radioWeekly.Checked) {
  163.                 $dflag = ""
  164.                 $checkboxes|foreach {
  165.                     if ($_.checked) {
  166.                         $dflag += $_.text.substring(0,3) + ","                        
  167.                     }
  168.                 }
  169.                 if ($dflag -ne "") {        
  170.                     $dflag = $dflag.substring(0,$dflag.length-1)
  171.                     & schtasks /create /tn $taskname /tr $taskrun /sc weekly /st $comboTime.Text /d "$dflag" /f
  172.                     $SchedulePickerForm.Close()
  173.                 }
  174.                 else {
  175.                     [System.windows.forms.messagebox]::show("You must select at least one day for weekly recurrence")
  176.                 }
  177.             }
  178.         }
  179.  
  180.     }
  181.  
  182.     $OnLoadForm_StateCorrection={
  183.         #Correct the initial state of the form to prevent the .Net maximized form issue
  184.         $SchedulePickerForm.WindowState = $InitialFormWindowState
  185.     }
  186.  
  187.     $SchedulePickerForm.Text = "Schedule Picker"
  188.     $SchedulePickerForm.MaximizeBox = $False
  189.     $SchedulePickerForm.Name = "SchedulePickerForm"
  190.     $SchedulePickerForm.DataBindings.DefaultDataSourceUpdateMode = 0
  191.     $System_Drawing_Size = New-Object System.Drawing.Size
  192.     $System_Drawing_Size.Width = 476
  193.     $System_Drawing_Size.Height = 157
  194.     $SchedulePickerForm.ClientSize = $System_Drawing_Size
  195.     $SchedulePickerForm.FormBorderStyle = 5
  196.  
  197.     $comboTime.FormattingEnabled = $True
  198.     $System_Drawing_Size = New-Object System.Drawing.Size
  199.     $System_Drawing_Size.Width = 121
  200.     $System_Drawing_Size.Height = 21
  201.     $comboTime.Size = $System_Drawing_Size
  202.     $comboTime.DataBindings.DefaultDataSourceUpdateMode = 0
  203.     $comboTime.Name = "comboTime"
  204.     $comboTime.Items.Add("00:00")|Out-Null
  205.     $comboTime.Items.Add("00:30")|Out-Null
  206.     $comboTime.Items.Add("01:00")|Out-Null
  207.     $comboTime.Items.Add("01:30")|Out-Null
  208.     $comboTime.Items.Add("02:00")|Out-Null
  209.     $comboTime.Items.Add("02:30")|Out-Null
  210.     $comboTime.Items.Add("03:00")|Out-Null
  211.     $comboTime.Items.Add("03:30")|Out-Null
  212.     $comboTime.Items.Add("04:00")|Out-Null
  213.     $comboTime.Items.Add("04:30")|Out-Null
  214.     $comboTime.Items.Add("05:00")|Out-Null
  215.     $comboTime.Items.Add("05:30")|Out-Null
  216.     $comboTime.Items.Add("06:00")|Out-Null
  217.     $comboTime.Items.Add("06:30")|Out-Null
  218.     $comboTime.Items.Add("07:00")|Out-Null
  219.     $comboTime.Items.Add("07:30")|Out-Null
  220.     $comboTime.Items.Add("08:00")|Out-Null
  221.     $comboTime.Items.Add("08:30")|Out-Null
  222.     $comboTime.Items.Add("09:00")|Out-Null
  223.     $comboTime.Items.Add("09:30")|Out-Null
  224.     $comboTime.Items.Add("10:00")|Out-Null
  225.     $comboTime.Items.Add("10:30")|Out-Null
  226.     $comboTime.Items.Add("11:00")|Out-Null
  227.     $comboTime.Items.Add("11:30")|Out-Null
  228.     $comboTime.Items.Add("12:00")|Out-Null
  229.     $comboTime.Items.Add("12:30")|Out-Null
  230.     $comboTime.Items.Add("13:00")|Out-Null
  231.     $comboTime.Items.Add("13:30")|Out-Null
  232.     $comboTime.Items.Add("14:00")|Out-Null
  233.     $comboTime.Items.Add("14:30")|Out-Null
  234.     $comboTime.Items.Add("15:00")|Out-Null
  235.     $comboTime.Items.Add("15:30")|Out-Null
  236.     $comboTime.Items.Add("16:00")|Out-Null
  237.     $comboTime.Items.Add("16:30")|Out-Null
  238.     $comboTime.Items.Add("17:00")|Out-Null
  239.     $comboTime.Items.Add("17:30")|Out-Null
  240.     $comboTime.Items.Add("18:00")|Out-Null
  241.     $comboTime.Items.Add("18:30")|Out-Null
  242.     $comboTime.Items.Add("19:00")|Out-Null
  243.     $comboTime.Items.Add("19:30")|Out-Null
  244.     $comboTime.Items.Add("20:00")|Out-Null
  245.     $comboTime.Items.Add("20:30")|Out-Null
  246.     $comboTime.Items.Add("21:00")|Out-Null
  247.     $comboTime.Items.Add("21:30")|Out-Null
  248.     $comboTime.Items.Add("22:00")|Out-Null
  249.     $comboTime.Items.Add("22:30")|Out-Null
  250.     $comboTime.Items.Add("23:00")|Out-Null
  251.     $comboTime.Items.Add("23:30")|Out-Null
  252.     $comboTime.Text = "08:00"
  253.     $comboTime.DropDownStyle = "DropDownList"
  254.    
  255.     $System_Drawing_Point = New-Object System.Drawing.Point
  256.     $System_Drawing_Point.X = 53
  257.     $System_Drawing_Point.Y = 119
  258.     $comboTime.Location = $System_Drawing_Point
  259.     $comboTime.TabIndex = 1
  260.  
  261.     $SchedulePickerForm.Controls.Add($comboTime)
  262.  
  263.     $label4.TabIndex = 3
  264.     $label4.TextAlign = 16
  265.     $System_Drawing_Size = New-Object System.Drawing.Size
  266.     $System_Drawing_Size.Width = 35
  267.     $System_Drawing_Size.Height = 23
  268.     $label4.Size = $System_Drawing_Size
  269.     $label4.Text = "Start:"
  270.  
  271.     $System_Drawing_Point = New-Object System.Drawing.Point
  272.     $System_Drawing_Point.X = 12
  273.     $System_Drawing_Point.Y = 116
  274.     $label4.Location = $System_Drawing_Point
  275.     $label4.DataBindings.DefaultDataSourceUpdateMode = 0
  276.     $label4.Name = "label4"
  277.  
  278.     $SchedulePickerForm.Controls.Add($label4)
  279.  
  280.     $buttonCancel.TabIndex = 3
  281.     $buttonCancel.Name = "buttonCancel"
  282.     $System_Drawing_Size = New-Object System.Drawing.Size
  283.     $System_Drawing_Size.Width = 75
  284.     $System_Drawing_Size.Height = 23
  285.     $buttonCancel.Size = $System_Drawing_Size
  286.     $buttonCancel.UseVisualStyleBackColor = $True
  287.  
  288.     $buttonCancel.Text = "Cancel"
  289.  
  290.     $System_Drawing_Point = New-Object System.Drawing.Point
  291.     $System_Drawing_Point.X = 368
  292.     $System_Drawing_Point.Y = 119
  293.     $buttonCancel.Location = $System_Drawing_Point
  294.     $buttonCancel.DataBindings.DefaultDataSourceUpdateMode = 0
  295.     $buttonCancel.add_Click($buttonCancel_OnClick)
  296.  
  297.     $SchedulePickerForm.Controls.Add($buttonCancel)
  298.  
  299.     $buttonOK.TabIndex = 2
  300.     $buttonOK.Name = "buttonOK"
  301.     $System_Drawing_Size = New-Object System.Drawing.Size
  302.     $System_Drawing_Size.Width = 75
  303.     $System_Drawing_Size.Height = 23
  304.     $buttonOK.Size = $System_Drawing_Size
  305.     $buttonOK.UseVisualStyleBackColor = $True
  306.  
  307.     $buttonOK.Text = "OK"
  308.  
  309.     $System_Drawing_Point = New-Object System.Drawing.Point
  310.     $System_Drawing_Point.X = 287
  311.     $System_Drawing_Point.Y = 119
  312.     $buttonOK.Location = $System_Drawing_Point
  313.     $buttonOK.DataBindings.DefaultDataSourceUpdateMode = 0
  314.     $buttonOK.add_Click($buttonOK_OnClick)
  315.  
  316.     $SchedulePickerForm.Controls.Add($buttonOK)
  317.  
  318.     $group.Name = "group"
  319.  
  320.     $group.Text = "Recurrence pattern"
  321.     $System_Drawing_Size = New-Object System.Drawing.Size
  322.     $System_Drawing_Size.Width = 431
  323.     $System_Drawing_Size.Height = 101
  324.     $group.Size = $System_Drawing_Size
  325.     $System_Drawing_Point = New-Object System.Drawing.Point
  326.     $System_Drawing_Point.X = 12
  327.     $System_Drawing_Point.Y = 12
  328.     $group.Location = $System_Drawing_Point
  329.     $group.TabStop = $False
  330.     $group.TabIndex = 0
  331.     $group.DataBindings.DefaultDataSourceUpdateMode = 0
  332.  
  333.     $SchedulePickerForm.Controls.Add($group)
  334.  
  335.     $checkSaturday.UseVisualStyleBackColor = $True
  336.     $System_Drawing_Size = New-Object System.Drawing.Size
  337.     $System_Drawing_Size.Width = 73
  338.     $System_Drawing_Size.Height = 24
  339.     $checkSaturday.Size = $System_Drawing_Size
  340.     $checkSaturday.TabIndex = 13
  341.     $checkSaturday.Text = "Saturday"
  342.     $System_Drawing_Point = New-Object System.Drawing.Point
  343.     $System_Drawing_Point.X = 274
  344.     $System_Drawing_Point.Y = 64
  345.     $checkSaturday.Location = $System_Drawing_Point
  346.     $checkSaturday.DataBindings.DefaultDataSourceUpdateMode = 0
  347.     $checkSaturday.Name = "checkSaturday"
  348.  
  349.     $checkSaturday.Visible = $False
  350.  
  351.     $group.Controls.Add($checkSaturday)
  352.  
  353.  
  354.     $checkFriday.UseVisualStyleBackColor = $True
  355.     $System_Drawing_Size = New-Object System.Drawing.Size
  356.     $System_Drawing_Size.Width = 64
  357.     $System_Drawing_Size.Height = 24
  358.     $checkFriday.Size = $System_Drawing_Size
  359.     $checkFriday.TabIndex = 12
  360.     $checkFriday.Text = "Friday"
  361.     $System_Drawing_Point = New-Object System.Drawing.Point
  362.     $System_Drawing_Point.X = 204
  363.     $System_Drawing_Point.Y = 64
  364.     $checkFriday.Location = $System_Drawing_Point
  365.     $checkFriday.DataBindings.DefaultDataSourceUpdateMode = 0
  366.     $checkFriday.Name = "checkFriday"
  367.  
  368.     $checkFriday.Visible = $False
  369.  
  370.     $group.Controls.Add($checkFriday)
  371.  
  372.  
  373.     $checkThursday.UseVisualStyleBackColor = $True
  374.     $System_Drawing_Size = New-Object System.Drawing.Size
  375.     $System_Drawing_Size.Width = 70
  376.     $System_Drawing_Size.Height = 24
  377.     $checkThursday.Size = $System_Drawing_Size
  378.     $checkThursday.TabIndex = 11
  379.     $checkThursday.Text = "Thursday"
  380.     $System_Drawing_Point = New-Object System.Drawing.Point
  381.     $System_Drawing_Point.X = 129
  382.     $System_Drawing_Point.Y = 64
  383.     $checkThursday.Location = $System_Drawing_Point
  384.     $checkThursday.DataBindings.DefaultDataSourceUpdateMode = 0
  385.     $checkThursday.Name = "checkThursday"
  386.  
  387.     $checkThursday.Visible = $False
  388.  
  389.     $group.Controls.Add($checkThursday)
  390.  
  391.  
  392.     $checkWednesday.UseVisualStyleBackColor = $True
  393.     $System_Drawing_Size = New-Object System.Drawing.Size
  394.     $System_Drawing_Size.Width = 83
  395.     $System_Drawing_Size.Height = 24
  396.     $checkWednesday.Size = $System_Drawing_Size
  397.     $checkWednesday.TabIndex = 10
  398.     $checkWednesday.Text = "Wednesday"
  399.     $System_Drawing_Point = New-Object System.Drawing.Point
  400.     $System_Drawing_Point.X = 342
  401.     $System_Drawing_Point.Y = 44
  402.     $checkWednesday.Location = $System_Drawing_Point
  403.     $checkWednesday.DataBindings.DefaultDataSourceUpdateMode = 0
  404.     $checkWednesday.Name = "checkWednesday"
  405.  
  406.     $checkWednesday.Visible = $False
  407.  
  408.     $group.Controls.Add($checkWednesday)
  409.  
  410.  
  411.     $checkTuesday.UseVisualStyleBackColor = $True
  412.     $System_Drawing_Size = New-Object System.Drawing.Size
  413.     $System_Drawing_Size.Width = 68
  414.     $System_Drawing_Size.Height = 24
  415.     $checkTuesday.Size = $System_Drawing_Size
  416.     $checkTuesday.TabIndex = 9
  417.     $checkTuesday.Text = "Tuesday"
  418.     $System_Drawing_Point = New-Object System.Drawing.Point
  419.     $System_Drawing_Point.X = 274
  420.     $System_Drawing_Point.Y = 44
  421.     $checkTuesday.Location = $System_Drawing_Point
  422.     $checkTuesday.DataBindings.DefaultDataSourceUpdateMode = 0
  423.     $checkTuesday.Name = "checkTuesday"
  424.  
  425.     $checkTuesday.Visible = $False
  426.  
  427.     $group.Controls.Add($checkTuesday)
  428.  
  429.  
  430.     $checkMonday.UseVisualStyleBackColor = $True
  431.     $System_Drawing_Size = New-Object System.Drawing.Size
  432.     $System_Drawing_Size.Width = 64
  433.     $System_Drawing_Size.Height = 24
  434.     $checkMonday.Size = $System_Drawing_Size
  435.     $checkMonday.TabIndex = 8
  436.     $checkMonday.Text = "Monday"    
  437.     $System_Drawing_Point = New-Object System.Drawing.Point
  438.     $System_Drawing_Point.X = 204
  439.     $System_Drawing_Point.Y = 44
  440.     $checkMonday.Location = $System_Drawing_Point
  441.     $checkMonday.DataBindings.DefaultDataSourceUpdateMode = 0
  442.     $checkMonday.Name = "checkMonday"
  443.  
  444.     $checkMonday.Visible = $False
  445.  
  446.     $group.Controls.Add($checkMonday)
  447.  
  448.  
  449.     $checkSunday.UseVisualStyleBackColor = $True
  450.     $System_Drawing_Size = New-Object System.Drawing.Size
  451.     $System_Drawing_Size.Width = 104
  452.     $System_Drawing_Size.Height = 24
  453.     $checkSunday.Size = $System_Drawing_Size
  454.     $checkSunday.TabIndex = 7
  455.     $checkSunday.Text = "Sunday"
  456.     $System_Drawing_Point = New-Object System.Drawing.Point
  457.     $System_Drawing_Point.X = 129
  458.     $System_Drawing_Point.Y = 44
  459.     $checkSunday.Location = $System_Drawing_Point
  460.     $checkSunday.DataBindings.DefaultDataSourceUpdateMode = 0
  461.     $checkSunday.Name = "checkSunday"
  462.  
  463.     $checkSunday.Visible = $False
  464.  
  465.     $group.Controls.Add($checkSunday)
  466.  
  467.     $labelDays.TabIndex = 6
  468.     $System_Drawing_Size = New-Object System.Drawing.Size
  469.     $System_Drawing_Size.Width = 64
  470.     $System_Drawing_Size.Height = 18
  471.     $labelDays.Size = $System_Drawing_Size
  472.     $labelDays.Visible = $False
  473.     $labelDays.Text = "day(s)"
  474.  
  475.     $System_Drawing_Point = New-Object System.Drawing.Point
  476.     $System_Drawing_Point.X = 189
  477.     $System_Drawing_Point.Y = 23
  478.     $labelDays.Location = $System_Drawing_Point
  479.     $labelDays.DataBindings.DefaultDataSourceUpdateMode = 0
  480.     $labelDays.Name = "labelDays"
  481.  
  482.     $group.Controls.Add($labelDays)
  483.  
  484.     $labelHours.TabIndex = 5
  485.     $System_Drawing_Size = New-Object System.Drawing.Size
  486.     $System_Drawing_Size.Width = 100
  487.     $System_Drawing_Size.Height = 23
  488.     $labelHours.Size = $System_Drawing_Size
  489.     $labelHours.Text = "hour(s)"
  490.  
  491.     $System_Drawing_Point = New-Object System.Drawing.Point
  492.     $System_Drawing_Point.X = 189
  493.     $System_Drawing_Point.Y = 23
  494.     $labelHours.Location = $System_Drawing_Point
  495.     $labelHours.DataBindings.DefaultDataSourceUpdateMode = 0
  496.     $labelHours.Name = "labelHours"
  497.  
  498.     $group.Controls.Add($labelHours)
  499.  
  500.     $System_Drawing_Size = New-Object System.Drawing.Size
  501.     $System_Drawing_Size.Width = 28
  502.     $System_Drawing_Size.Height = 20
  503.     $boxHourlyDaily.Size = $System_Drawing_Size
  504.     $boxHourlyDaily.DataBindings.DefaultDataSourceUpdateMode = 0
  505.     $boxHourlyDaily.Text = "1"
  506.     $boxHourlyDaily.Name = "boxHourlyDaily"
  507.     $System_Drawing_Point = New-Object System.Drawing.Point
  508.     $System_Drawing_Point.X = 155
  509.     $System_Drawing_Point.Y = 20
  510.     $boxHourlyDaily.Location = $System_Drawing_Point
  511.     $boxHourlyDaily.TabIndex = 4
  512.  
  513.     $group.Controls.Add($boxHourlyDaily)
  514.  
  515.     $labelEvery.TabIndex = 3
  516.     $System_Drawing_Size = New-Object System.Drawing.Size
  517.     $System_Drawing_Size.Width = 67
  518.     $System_Drawing_Size.Height = 23
  519.     $labelEvery.Size = $System_Drawing_Size
  520.     $labelEvery.Text = "Every"
  521.  
  522.     $System_Drawing_Point = New-Object System.Drawing.Point
  523.     $System_Drawing_Point.X = 116
  524.     $System_Drawing_Point.Y = 23
  525.     $labelEvery.Location = $System_Drawing_Point
  526.     $labelEvery.DataBindings.DefaultDataSourceUpdateMode = 0
  527.     $labelEvery.Name = "labelEvery"
  528.  
  529.     $group.Controls.Add($labelEvery)
  530.  
  531.     $radioHourly.TabIndex = 0
  532.     $radioHourly.Name = "radioHourly"
  533.     $System_Drawing_Size = New-Object System.Drawing.Size
  534.     $System_Drawing_Size.Width = 104
  535.     $System_Drawing_Size.Height = 24
  536.     $radioHourly.Size = $System_Drawing_Size
  537.     $radioHourly.UseVisualStyleBackColor = $True
  538.  
  539.     $radioHourly.Text = "Hourly"
  540.     $radioHourly.Checked = $True
  541.  
  542.     $System_Drawing_Point = New-Object System.Drawing.Point
  543.     $System_Drawing_Point.X = 6
  544.     $System_Drawing_Point.Y = 17
  545.     $radioHourly.Location = $System_Drawing_Point
  546.     $radioHourly.DataBindings.DefaultDataSourceUpdateMode = 0
  547.     $radioHourly.TabStop = $True
  548.     $radioHourly.add_Click($handler_radioButtonChanged)
  549.    
  550.     $group.Controls.Add($radioHourly)
  551.  
  552.     $radioWeekly.TabIndex = 2
  553.     $radioWeekly.Name = "radioWeekly"
  554.     $System_Drawing_Size = New-Object System.Drawing.Size
  555.     $System_Drawing_Size.Width = 104
  556.     $System_Drawing_Size.Height = 24
  557.     $radioWeekly.Size = $System_Drawing_Size
  558.     $radioWeekly.UseVisualStyleBackColor = $True
  559.  
  560.     $radioWeekly.Text = "Weekly"
  561.  
  562.     $System_Drawing_Point = New-Object System.Drawing.Point
  563.     $System_Drawing_Point.X = 6
  564.     $System_Drawing_Point.Y = 56
  565.     $radioWeekly.Location = $System_Drawing_Point
  566.     $radioWeekly.DataBindings.DefaultDataSourceUpdateMode = 0
  567.     $radioWeekly.add_Click($handler_radioButtonChanged)
  568.  
  569.     $group.Controls.Add($radioWeekly)
  570.  
  571.     $radioDaily.TabIndex = 1
  572.     $radioDaily.Name = "radioDaily"
  573.     $System_Drawing_Size = New-Object System.Drawing.Size
  574.     $System_Drawing_Size.Width = 104
  575.     $System_Drawing_Size.Height = 24
  576.     $radioDaily.Size = $System_Drawing_Size
  577.     $radioDaily.UseVisualStyleBackColor = $True
  578.  
  579.     $radioDaily.Text = "Daily"
  580.  
  581.     $System_Drawing_Point = New-Object System.Drawing.Point
  582.     $System_Drawing_Point.X = 6
  583.     $System_Drawing_Point.Y = 37
  584.     $radioDaily.Location = $System_Drawing_Point
  585.     $radioDaily.DataBindings.DefaultDataSourceUpdateMode = 0
  586.     $radioDaily.add_Click($handler_radioButtonChanged)
  587.  
  588.     $group.Controls.Add($radioDaily)
  589.    
  590.     $SchedulePickerForm.CancelButton = $buttonCancel
  591.     $SchedulePickerForm.AcceptButton = $buttonOK
  592.  
  593.     #Save the initial state of the form
  594.     $InitialFormWindowState = $SchedulePickerForm.WindowState
  595.     #Init the OnLoad event to correct the initial state of the form
  596.     $SchedulePickerForm.add_Load($OnLoadForm_StateCorrection)
  597.     #Show the Form
  598.     $SchedulePickerForm.ShowDialog() |out-null
  599.  
  600. }

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me