Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

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.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Pop-up to enter variables to pass to script

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 11-15-2007   #1 (permalink)
Anatoli
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 SpecsSystem Spec
Old 11-16-2007   #2 (permalink)
Shay Levi
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


Quote:

> 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 SpecsSystem Spec
Old 11-17-2007   #3 (permalink)
Anatoli
Guest


 

Re: Pop-up to enter variables to pass to script

Thanks Shay, that worked well.

"Shay Levi" wrote:
Quote:

> 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
>
>
>
Quote:

> > 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 SpecsSystem Spec
Closed Thread

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


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

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 42 43 44 45 46 47 48 49 50 51