I'm looking to setup a GUI that will determine the next step of a first time setup application. I originally programed the whole thing using batch but would like a more user friendly look. The program basically uninstalls bloatware that computer manufacturers load on their computers and installs some useful programs. This is my first time using PowerShell. This is what I have so far:
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$objForm = New-Object System.Windows.Forms.Form
$objForm.Text = "Pauk Inc."
$objForm.Size = New-Object System.Drawing.Size(300,175)
$objForm.StartPosition = "CenterScreen"
$objForm.KeyPreview = $True
$objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter")
{$x=$objTextBox.Text;$objForm.Close()}})
$objForm.Add_KeyDown({if ($_.KeyCode -eq "Escape")
{$objForm.Close()}})
$YesButton = New-Object System.Windows.Forms.Button
$YesButton.Location = New-Object System.Drawing.Size(70,95)
$YesButton.Size = New-Object System.Drawing.Size(75,23)
$YesButton.Text = "Sure"
$YesButton.Add_Click({$x=$objTextBox.Text;$objForm.Close()})
$objForm.Controls.Add($YesButton)
$NoButton = New-Object System.Windows.Forms.Button
$NoButton.Location = New-Object System.Drawing.Size(155,95)
$NoButton.Size = New-Object System.Drawing.Size(75,23)
$NoButton.Text = "No Thanks"
$NoButton.Add_Click({$objForm.Close()})
$objForm.Controls.Add($NoButton)
$objLabel = New-Object System.Windows.Forms.Label
$objLabel.Location = New-Object System.Drawing.Size(55,50)
$objLabel.Size = New-Object System.Drawing.Size(280,25)
$objLabel.Text = "Would you like to install Anti Virus?"
$objForm.Controls.Add($objLabel)
$objForm.Topmost = $True
$objForm.Add_Shown({$objForm.Activate()})
[void] $objForm.ShowDialog()
$x
Essentially what I'm looking to do is Install the AV if they click "Sure", and don't if they click "No Thanks".
echo Do you want to continue? (y or n)set p/ answer=and whatever the person types tells the program what to follow next.if %answer% == y goto yesif %answer% == n goto noI want to do the same thing except in PowerShell and with a click of a button rather than typing y or n.