A
A
Alexander Pavlov2020-02-07 16:10:41
PowerShell
Alexander Pavlov, 2020-02-07 16:10:41

Forms.TextBox in PowerShell passes technical information, how to pass text?

Hello.

I'm trying to write a small script to send messages to users on the local network.

But for some reason, technical information is transmitted from the TextBox along with the entered text.

Any ideas how to fix it?

$ErrorActionPreference = "silentlycontinue"

# Подключаем то, с помощью чего будем рисовать нашу форму
Add-Type -assembly System.Windows.Forms

$mainWindow = New-Object System.Windows.Forms.Form
$mainWindow.Width = 400
$mainWindow.Height = 400

$proverka = New-Object System.Windows.Forms.TextBox
$proverka.Location = New-Object System.Drawing.Point(20,50)
$proverka.Size = New-Object System.Drawing.Size(150,20)
$proverka.Text = "Проверка"
$mainWindow.Controls.Add($proverka)

$button = New-Object System.Windows.Forms.Button
$button.Location = New-Object System.Drawing.Point(20,70)
$button.Size = New-Object System.Drawing.Size(150,20)
$button.Text = "Отправить"
$mainWindow.Controls.Add($button)

$button.Add_Click({
    $request = $proverka.Text
    c:\windows\system32\msg.exe * /Server:localhost $proverka
})



$mainWindow.ShowDialog()


5e3d61ba65649957274179.jpeg

An allegedly ready-made script is walking on the Internet, do not give a link, it is not working.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
azarij, 2020-02-07
@Sanchez9891

c:\windows\system32\msg.exe * /Server:localhost $proverka
should be:
c:\windows\system32\msg.exe * /Server:localhost $request
or
c:\windows\system32\msg.exe * / Server:localhost $proverka.text

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question