Answer the question
In order to leave comments, you need to log in
How to "Create a Solution"?
Good afternoon.
Picking homemade:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//string = textBox2.Text;
//label2.Text = Text;
string Pc = textBox2.Text;
ProcessStartInfo psiOpt = new ProcessStartInfo("cmd.exe", "/c ping 192.168.1." + Pc) {
StandardOutputEncoding = Encoding.GetEncoding(866)// устанавливаем кодировку выводимого
};
// скрываем окно запущенного процесса
psiOpt.WindowStyle = ProcessWindowStyle.Hidden;
psiOpt.RedirectStandardOutput = true;
psiOpt.UseShellExecute = false;
psiOpt.CreateNoWindow = true; //не показывать cmd
// запускаем процесс
Process procCommand = Process.Start(psiOpt);
// получаем ответ запущенного процесса
StreamReader srIncoming = procCommand.StandardOutput;
// закрываем процесс
procCommand.WaitForExit();
// выводим результат
textBox3.Text = srIncoming.ReadToEnd();
}
}
}
Answer the question
In order to leave comments, you need to log in
And if you copy the entire folder C:\Users\pupkin\source\repos\WindowsFormsApp1\WindowsFormsApp1\bin\Debug and run the executable from there?
When creating a finished program, it is better to choose the Release build configuration, and then the entire C:\Users\pupkin\source\repos\WindowsFormsApp1\WindowsFormsApp1\bin\Release folder will become the distribution kit of the program, especially all dlls. You can try to remove the "extra" files from the folder, but .exe and .dll are all usually needed.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question