Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Pop-up to enter variables to pass to script

Reply
 
Old 11-15-2007   #1 (permalink)
Anatoli


 
 

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


 
 

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


 
 

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
Reply

Thread Tools


Similar Threads
Thread Forum
VBS Telnet to Server and Pass Variables for User and Password?? VB Script
Include another script, keep variables in included script? PowerShell
Outputting variables & accepting keystrokes without pressing enter PowerShell
Need help with PHP Script variables Network & Sharing
how do you pass named params to funcs by way of variables PowerShell


Vista Forums 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 Ltd

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