1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| Add-Type AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$MainForm = New-Object System.Windows.Forms.Form
$MainForm.Text="PrinterInstaller"
$MainForm.StartPosition = "CenterScreen"
$MainForm.Width = 500
$MainForm.Height = 500
$MainForm.TopMost = $True
$MainForm.Add_Shown({$tBoxcomp.Select()})
Function Testping {
Param($Computername)
if (Test-Connection -$Computername -Quiet) {write 'ok'} else {write 'nok'}
}
Function Ecrit ($nom)
{Write-Host $nom}
$labelordi = New-Object System.Windows.Forms.Label
$labelordi.Location = New-Object System.Drawing.Point(10,20)
$labelordi.Size = New-Object System.Drawing.Size(120,20)
$labelordi.Text = 'Nom de l''ordinateur :'
$MainForm.Controls.Add($labelordi)
$tBoxcomp = New-Object System.Windows.Forms.TextBox
$tBoxcomp.Location = New-Object System.Drawing.Point(10,40)
$tBoxcomp.Size = New-Object System.Drawing.Size(100,20)
$Comp=$tBoxcomp.text
$tBoxcomp.add_Leave({Ecrit $Comp})
$tBoxcomp.add_Leave({Testping $Comp})
$MainForm.Controls.Add($tBoxcomp)
$MainForm.ShowDialog() |
Partager