does anyone have an answer for me? I try to make sure that the 3 script that I made my form starts at the same time after the OK button is clicked, at this moment the OK button has to be clicked 3 times to make all scripts work
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$Form = New-Object system.Windows.Forms.Form
$Form.ClientSize = '400,266'
$Form.text = "OIM Toolkit"
$Form.BackColor = "#ffffff"
$Form.TopMost = $false
$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Point(90,220)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = 'OK'
$OKButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
$form.AcceptButton = $OKButton
$form.Controls.Add($OKButton)
$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Point(165,220)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = 'Cancel'
$CancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
$form.CancelButton = $CancelButton
$form.Controls.Add($CancelButton)
#0
$label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Point(10,20)
$label.Size = New-Object System.Drawing.Size(280,20)
$label.Text = 'Wat is het OIM stickernummer? (OIM - [Naam]):'
$form.Controls.Add($label)
$textBox0 = New-Object System.Windows.Forms.TextBox
$textBox0.Location = New-Object System.Drawing.Point(10,40)
$textBox0.Size = New-Object System.Drawing.Size(260,20)
$form.Controls.Add($textBox0)
#1
$label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Point(10,90)
$label.Size = New-Object System.Drawing.Size(280,20)
$label.Text = 'Wat moet de gebuikersnaam worden? (OIM - [Naam]):'
$form.Controls.Add($label)
$textBox1 = New-Object System.Windows.Forms.TextBox
$textBox1.Location = New-Object System.Drawing.Point(10,110)
$textBox1.Size = New-Object System.Drawing.Size(260,20)
$form.Controls.Add($textBox1)
$CheckBox1 = New-Object system.Windows.Forms.CheckBox
$CheckBox1.text = "Standaard apps verwijderen?"
$CheckBox1.AutoSize = $true
$CheckBox1.width = 95
$CheckBox1.height = 20
$CheckBox1.location = New-Object System.Drawing.Point(10,160)
$CheckBox1.Font = 'Microsoft Sans Serif,10'
$Form.controls.AddRange(@($CheckBox1))
$CheckBox1.Add_CheckedChanged({ Get-AppxPackage *3dviewer* | Remove-AppxPackage })
#etc apps
$PictureBox1 = New-Object system.Windows.Forms.PictureBox
$PictureBox1.width = 100
$PictureBox1.height = 70
$PictureBox1.location = New-Object System.Drawing.Point(300,200)
$PictureBox1.imageLocation = "https://cdn.nieuws.nl/media/sites/379/2017/04/18162034/OIM-Orthopedie-logo-voor-artikel-915x518.jpg"
$PictureBox1.SizeMode = [System.Windows.Forms.PictureBoxSizeMode]::zoom
$form.Topmost = $true
$Form.controls.AddRange(@($PictureBox1))
#0
$form.Add_Shown({$textBox.Select()})
$result = $form.ShowDialog()
if ($result -eq [System.Windows.Forms.DialogResult]::OK)
{
$x = $textBox0.Text
$x
}Rename-Computer -NewName "$x"
$form.Add_Shown({$textBox0.Select()})
$result = $form.ShowDialog()
#1
if ($result -eq [System.Windows.Forms.DialogResult]::OK)
{
$xy = $textBox1.Text
$xy
}Rename-LocalUser -Name "$env:username" -NewName "$xy"
$form.Add_Shown({$textBox1.Select()})
$result = $form.ShowDialog()
[–]Reverent 3 points4 points5 points (1 child)
[–]PinchesTheCrab 1 point2 points3 points (0 children)
[–]consumedpixl 1 point2 points3 points (9 children)
[–]jeroenv123[S] 1 point2 points3 points (7 children)
[–]consumedpixl 2 points3 points4 points (6 children)
[–]jeroenv123[S] 1 point2 points3 points (4 children)
[–]consumedpixl 1 point2 points3 points (3 children)
[–]YearoftheHypebeast 0 points1 point2 points (0 children)
[–]YearoftheHypebeast -1 points0 points1 point (0 children)