Advertisement
Combreal

SimpleGUI-01.ps1

Aug 23rd, 2023
1,054
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
  2. [reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null
  3.  
  4. $GUI = New-Object System.Windows.Forms.Form
  5. $GUI.Text = "Compliance Checker"
  6. $GUI.Name = "ComplianceC"
  7. $GUI.DataBindings.DefaultDataSourceUpdateMode = 0
  8. $GUI.ClientSize = New-Object System.Drawing.Size(500,349)
  9. #$objIcon = [System.IconExtractor]::Extract("C:\Windows\System32\shell32.dll", $IconIndexNo, $true)
  10. #shell32 ddores imageres pifmgr accessibilitycpl mmcndmgr mmres netcenter netshell networkexplorer pnidui sensorscpl setupapi wmploc  
  11. #ieframe dmdskres dsuiext mstscax wiashext comres autoplay comctl32 filemgmt xwizards compstui mstsc actioncentercpl aclui wpdshext
  12. #good ones : sensorscpl  compstui  ieframe  wiashext  comres  actioncentercpl aclui filemgmt
  13. $objIcon = [System.Drawing.Icon]::ExtractAssociatedIcon("C:\Windows\System32\actioncentercpl.dll")
  14. $GUI.Icon = $objIcon
  15.  
  16. $label = New-Object Windows.Forms.Label
  17. $label.Location = New-Object Drawing.Point 50,30
  18. $label.Size = New-Object Drawing.Point 200,15
  19. $label.text = "Enter your name and click the button"
  20.  
  21. $textfield = New-Object Windows.Forms.TextBox
  22. $textfield.Location = New-Object Drawing.Point 50,60
  23. $textfield.Size = New-Object Drawing.Point 200,30
  24.  
  25. $button = New-Object Windows.Forms.Button
  26. $button.text = "Greeting"
  27. $button.Location = New-Object Drawing.Point 100,90
  28.  
  29. $button.add_click({
  30.     $label.Text = "Hello " + $textfield.text
  31. })
  32.  
  33. $GUI.controls.add($button)
  34. $GUI.controls.add($label)
  35. $GUI.controls.add($textfield)
  36. $GUI.ShowDialog()| Out-Null  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement