![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Pop-up to enter variables to pass to script Hi, I'd like to know how I create a pop-up, using .net, to populate it with variables that would be passed to my powershell script... thanks, |
My System Specs![]() |
| | #2 (permalink) | ||||||||||||
| Guest | Re: Pop-up to enter variables to pass to script Here's a snippet from Jeffrey Snover ITForum presentation. Save it as get-GuiInput.ps1 and execute it: #Requires -Version 1 param ( $pstring = "Name?", [regex]$validationString = ".*" ) [void][reflection.assembly]::LoadWithPartialName("System.Windows.Forms") ############################### # Create the form $form = New-Object System.Windows.Forms.Form $form.add_shown({$form.Activate()}) $form.Text = "PowerShell GUI Input" $form.height = 110 ############################### # Create the label $label = New-Object System.Windows.Forms.Label $label.Text = $pstring $label.dock = "top" ############################### # Create the textbox for input $textbox = new-object system.windows.forms.textbox $textbox.dock = "top" $textbox.add_KeyUp({ if ( $textbox.text -Notmatch $validationString ) { $textbox.BackColor = "RED" }else { $textbox.BackColor = "white" } }) ############################### # Create the OK button and when the OK button is clicked hide the form $OK = new-object system.windows.forms.button $OK.Text = "OK" $OK.dock = "bottom" $OK.Add_Click({ $form.hide() }) ############################### # add the controls to the form $form.Controls.AddRange(@($textbox,$label,$OK)) ############################### # show the form $results = $form.showdialog() # show the results $textbox.Text $form.dispose() ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com
| ||||||||||||
My System Specs![]() | |||||||||||||
| | #3 (permalink) | ||||||||||||||||||||||||
| Guest | Re: Pop-up to enter variables to pass to script Thanks Shay, that worked well. "Shay Levi" wrote:
| ||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Include another script, keep variables in included script? | pschmidt | PowerShell | 32 | 08-18-2008 01:48 PM |
| Outputting variables & accepting keystrokes without pressing enter | Kari | PowerShell | 1 | 08-08-2008 10:30 AM |
| Need help with PHP Script variables | Fmjc001 | Network & Internet | 3 | 07-20-2008 09:48 AM |
| how do you pass named params to funcs by way of variables | Bob Landau | PowerShell | 2 | 08-19-2007 08:04 PM |
| Passing variables to script | Anatoli | PowerShell | 7 | 08-07-2007 05:38 PM |