none
Input text box - variable RRS feed

  • Question

  • hello i need from the textbox remote computer when write computer name  , change the value of $a .Can help me?

                [void][System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
                 [void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
                 $Form = New-Object System.Windows.Forms.Form
                 $Form.Size = New-Object System.Drawing.Size(655, 530)
                 $Form.Text = "Vader"
                 $Form.StartPosition = "CenterScreen" #loads the window in the center of the screen
                 $Icon = [system.drawing.icon]::ExtractAssociatedIcon($PSHOME + "\powershell.exe")
                 $Form.MinimizeBox = $False
                 $Form.MaximizeBox = $False
                 $Form.WindowState = "Normal"
                 # Maximized, Minimized, Normal
                 $Form.SizeGripStyle = "Hide"
                 # Auto, Hide, Show
                 $Form.Icon = $Icon
    
             function sourcefolder
                 {
                $a = #  i need variable from $RemoteComputerInput
                        Add-Type -AssemblyName System.Windows.Forms
                        $FolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog
                         $FolderBrowser.Description = "Select a folder"
                        $FolderBrowser.SelectedPath = "\\$a\c$"
                        $FolderBrowser.ShowDialog()
                        $InputSource.text = $FolderBrowser.SelectedPath
                 }  
    
            #Button Source Folder
    
                 $ButtonSourceFolder = New-Object System.Windows.Forms.Button
                 $ButtonSourceFolder.Location = New-Object System.Drawing.Size(15, 15)
                 $ButtonSourceFolder.Size = New-Object System.Drawing.Size(120, 25)
                 $ButtonSourceFolder.Text = "Source Folder"
                 $ButtonSourceFolder.Add_Click({ sourcefolder })
                 $Form.Controls.Add($ButtonSourceFolder)            
    
                 #Source input
                 $InputSource = New-Object System.Windows.Forms.TextBox
                 $InputSource.Text = ""
                 $InputSource.Location = New-Object System.Drawing.Size(15, 45)
                 $InputSource.Size = New-Object System.Drawing.Size(365, 20)
                 $Form.Controls.Add($InputSource)            
    
            #Remote Computer label
                 $RemoteComputerLabel = New-Object System.Windows.Forms.Label
                 $RemoteComputerLabel.Text = "Remote Computer:"
                 $RemoteComputerLabel.Location = New-Object System.Drawing.Size(430, 100)
                 $RemoteComputerLabel.Size = New-Object System.Drawing.Size(170, 15)
                 $Form.Controls.Add($RemoteComputerLabel)            
    
                 #Remote Computer input
                 $RemoteComputerInput = New-Object System.Windows.Forms.TextBox
                 $RemoteComputerInput.Text = ""
                 $RemoteComputerInput.Location = New-Object System.Drawing.Size(430, 115)
                 $RemoteComputerInput.Size = New-Object System.Drawing.Size(170, 30)
                 $Form.Controls.Add($RemoteComputerInput)        
    
                 $Form.Add_Shown({ $Form.Activate() })
                 [void]$Form.ShowDialog()

    Sunday, March 15, 2020 9:55 AM

Answers

All replies

  • ineed from remote computer inputbox

    #Remote Computer input
                 $RemoteComputerInput = New-Object System.Windows.Forms.TextBox
                 $RemoteComputerInput.Text = ""
                 $RemoteComputerInput.Location = New-Object System.Drawing.Size(430, 115)
                 $RemoteComputerInput.Size = New-Object System.Drawing.Size(170, 30)
                 $Form.Controls.Add($RemoteComputerInput)        

    update : $FolderBrowser.SelectedPath = "\\$a\c$"   #variable $a

     function sourcefolder
                 {
                $a = #  i need variable from $RemoteComputerInput
                        Add-Type -AssemblyName System.Windows.Forms
                        $FolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog
                         $FolderBrowser.Description = "Select a folder"
                        $FolderBrowser.SelectedPath = "\\$a\c$"
                        $FolderBrowser.ShowDialog()
                        $InputSource.text = $FolderBrowser.SelectedPath
                 }  

    Sunday, March 15, 2020 10:05 AM
    • Marked as answer by Vader100 Sunday, March 15, 2020 3:55 PM
    Sunday, March 15, 2020 12:50 PM
  • I have this output : System.Windows.Forms.TextBox.Text:PC130219

      I need only  : PC130219

    #Remote Computer input
                 $RemoteComputerInput = New-Object System.Windows.Forms.TextBox
                 $RemoteComputerInput.Text = ""
                 $RemoteComputerInput.Location = New-Object System.Drawing.Size(430, 115)
                 $RemoteComputerInput.Size = New-Object System.Drawing.Size(170, 30)
                 $Form.Controls.Add($RemoteComputerInput)


    function sourcefolder
                 {
                        Add-Type -AssemblyName System.Windows.Forms
                        $FolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog
                        $FolderBrowser.Description = "Select a folder"
                        $FolderBrowser.SelectedPath = "\\$RemoteComputerInput\c$"
                        $FolderBrowser.ShowDialog()
                        $InputSource.text = $FolderBrowser.SelectedPath
                 }  


    Sunday, March 15, 2020 3:18 PM
  • Thanks, you are the best.
    Sunday, March 15, 2020 3:55 PM