Search code examples
c#batch-filecom0com

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.


Solution

  • 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();