-
Jul 26th, 2017, 02:55 AM
#1
Thread Starter
Junior Member
calling another exe in my c# code.
Hi all,
I have an exe MCP2210CLI placed at C:\Users\testuser\Desktop. I cannot run it directly by double clicking on it. So I use command prompt and execute the following.
C:\Users\testuser>cd desktop
C:\Users\testuser\Desktop>MCP2210CLI -devices
No devices connected.
I want to do these tasks in my c# code and generate the output in a command prompt.
I have written the following code. Howevwe an empty command prompt window opens. What change is needed in my code to get the exe running?
Process myProcess = new Process();
try
{
string dir = @"C:\Users\testuser\Desktop\";
Directory.SetCurrentDirectory(dir);
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo.FileName = @"C:\Users\testuser\Desktop\MCP2210CLI.exe";
myProcess.StartInfo.Arguments = "- devices";
myProcess.Start();
myProcess.WaitForExit();
}
catch (Exception e)
{
Console.WriteLine("error",e.Message);
}
Thanks in advance.
Last edited by dipk11; Jul 26th, 2017 at 03:50 AM.
-
Jul 26th, 2017, 03:30 AM
#2
Thread Starter
Junior Member
Re: calling another exe in my c# code.
This is a batch file I had created to get this work done.
@echo off
title SimpleEXE
echo Started Batch File
cd "C:\Users\testuser\Desktop"
CALL MCP2210CLI.exe -devices 1>stdout.txt
CALL MCP2210CLI.exe -devices>>file.txt
echo Trial EXE file 3
pause
If I replace CALL by START command,i do not get any output. Only wen I use CALL command I get the output printed on the command promt.
I want to write this in my c# code. kindly help me out.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|