Rajat Sehgal
asked on
How to Convert batch script to C# Windows Forms App
Hi Experts,
I've a batch script for pinging multipal ip's, now i want convert this batch script to C# Windows Forms App (.NET Framework) & run ping with start button.
Please Suggest ?
COLO.txt
COLOPINGLOOP.txt
I've a batch script for pinging multipal ip's, now i want convert this batch script to C# Windows Forms App (.NET Framework) & run ping with start button.
Please Suggest ?
COLO.txt
COLOPINGLOOP.txt
ASKER
I want to learn how to convert OR use batch script to C#. I've maximum program which is in batch script now need to convert with C#.
If you want to execute batch script by C# program, you can use this code:
Process proc = null;
try
{
string batchScriptDirectory = string.Format(@"YourDirectory");
proc = new Process();
proc.StartInfo.WorkingDirectory = batchScriptDirectory;
proc.StartInfo.FileName = "YourBatchFileName.bat";
proc.StartInfo.CreateNoWindow = false;
proc.Start();
proc.WaitForExit();
}
catch (Exception ex)
{
Console.WriteLine(ex.StackTrace.ToString());
}
Why create your own when there are free utils available that do this?
»bp
»bp
@Rajat Sehgal,
Are you all set with this now, or do you need more help? If all set, could you please close it out now. If you need help with the question close process take a look at:
»bp
Are you all set with this now, or do you need more help? If all set, could you please close it out now. If you need help with the question close process take a look at:
»bp
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
But I have to ask: Why? What problem try you to solve here? Or do you want to learn C#?