I am not very good at Powershell, so please bear with me if I ask questions which are easy to Powershell experts.
I have a Powershell script with 4 buttons, which each calls different .bat files I've written, to automatically backup my pictures and music and such, to my external harddrive and all that works perfectly.
Is there a way to make a marquee progressbar appear inside the window when a button is clicked? (strictly for good looks)
I have a code for a progressbar which works fine by itself, but can I make it appear when I click each button? Here is the code for the progressbar:
$progStrip = New-Object System.Windows.Forms.ProgressBar
$progStrip.Top = 70
$progStrip.Left = 10
$progStrip.Width = 515
$progStrip.Value = 0
$progStrip.Style="Marquee"
$progStrip.MarqueeAnimationSpeed = 50
$form.Controls.Add($progStrip)**
And here is my Powershell script with the button, that I want to trigger a progress bar, Marquee style for simplicity. Thank you very much in advance
Add-Type -AssemblyName System.Windows.Forms [System.Windows.Forms.Application]::EnableVisualStyles() $form = New-Object System.Windows.Forms.Form $form.Size = New-Object System.Drawing.Size(550,210) $form.Text = "System Backup" $form.FormBorderStyle = "FixedDialog" $form.StartPosition = "CenterScreen" $form.KeyPreview = $True $form.Add_KeyDown({if ($_.KeyCode -eq "Escape") {$form.Close()}}) $icon = [system.drawing.icon]::ExtractAssociatedIcon('D:\Documents\Andet\Icons\icon1 (3).ico') $form.Icon = $icon $statStrip = New-Object System.Windows.Forms.StatusStrip $statStrip.Items.Add("Backup via Powershell") | Out-Null $form.Controls.Add($statStrip) $1Button = New-Object System.Windows.Forms.Button $1Button.Location = New-Object System.Drawing.Size(10,100) $1Button.Size = New-Object System.Drawing.Size(125,40) $1Button.Text = "Saved games backup" $1Button.Add_Click({Start-Process "C:\Backup\Backup1.bat"}) $form.Controls.Add($1Button) $2Button = New-Object System.Windows.Forms.Button $2Button.Location = New-Object System.Drawing.Size(140,100) $2Button.Size = New-Object System.Drawing.Size(125,40) $2Button.Text = "Fuld backup til ekstern harddisk" $2Button.Add_Click({Start-Process "C:\Backup\Backup2.bat"}) $form.Controls.Add($2Button) $3Button = New-Object System.Windows.Forms.Button $3Button.Location = New-Object System.Drawing.Size(270,100) $3Button.Size = New-Object System.Drawing.Size(125,40) $3Button.Text = "Slet og omdb filer/mapper" $3Button.Add_Click({Start-Process "C:\Backup\Delete.bat"}) $form.Controls.Add($3Button) $4Button = New-Object System.Windows.Forms.Button $4Button.Location = New-Object System.Drawing.Size(400,100) $4Button.Size = New-Object System.Drawing.Size(125,40) $4Button.Text = "Afslut" $4Button.Add_Click({$form.Close()}) $form.Controls.Add($4Button) $objLabel = New-Object System.Windows.Forms.Label $objLabel.Location = New-Object System.Drawing.Size(185,15) $objLabel.Size = New-Object System.Drawing.Size(200,50) $objLabel.Font = New-Object System.Drawing.Font("Arial",15) $objLabel.Text = "Vlg backup type:" $form.Controls.Add($objLabel) $form.Topmost = $True $form.ShowDialog()