Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

creating a batch file in c#

This is my first time creating a batch. basically i want write commands in the command Promt. so i need batch file so that i can it in c# and does the task.

The commands looks like this:

install PortName=COM50-
bcdedit.exe -set TESTSIGNING OFF

How i can create the batch file and run it using c# code.

Thanks

Details: i am using com0com to create virtual ports, so the main idea is to automate the process, so i can create port without going to command port and write the commands.

like image 525
Liban Avatar asked May 16 '26 02:05

Liban


2 Answers

You maybe don't need a batch file :-

 Process myprocess = new Process();
 myprocess.StartInfo.FileName = @"C:\WHERE_EVER\bcdedit.exe";
 // I dont know the exact switch, but im sure you would be able to work this out.
 myprocess.StartInfo.Arguments = @"Install PortName=COM50 -set TESTSIGNING OFF";
 myprocess.Start();
like image 66
Derek Avatar answered May 17 '26 15:05

Derek


Write the commands to a file and call System.Diagnostics.Process.Start() with the path to the file.

like image 38
Zach Johnson Avatar answered May 17 '26 15:05

Zach Johnson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!