Click here to Skip to main content
15,895,740 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
hello

i am running one EXE application with 2 argument in cmd like this

"d:\work\sample.exe first second"

its working fine. but when i run EXE application throw code like this
C#
System.Diagnostics.Process process1 = new System.Diagnostics.Process();
process1.StartInfo.FileName = "d:\work\sample.exe");
process1.StartInfo.Arguments = "first second";
process1.Start();
process1.WaitForExit();
process1.Close();

its execute fine but give not any result.

this EXE applicaiton work with file.

whats have i done wrong.

also one thing i can also see the command window opening but its close after open, if its work fine then it can open for 10 sec. i don't understand the problem.

pls help me.
Posted
Updated 7-Nov-15 1:15am
v3
Comments
Afzaal Ahmad Zeeshan 7-Nov-15 6:42am    
Because the code runs on ASP.NET's server side, client won't know whether some process started or not! These APIs should be used on client-side, not on server-side.
Member 9735370 7-Nov-15 7:07am    
the code is on server side bro it has to work on client click
Afzaal Ahmad Zeeshan 7-Nov-15 7:16am    
Yes, I know, but how will client be notified of that process? That was my point.

The process that started on server-side cannot be notified to client unless you write something which streams down the "Process started..." string to client. I am sure the process was started, but since client is on browser. He was not notified.

If there had been a trouble, you would have got an exception, which is not a case here.
Member 9735370 7-Nov-15 7:28am    
thanks for your reply,leave the thing about client know the process but the main point is server side code is not run properly.
Gautham Prabhu K 7-Nov-15 10:42am    
Is it Asp.NET application(web based) or normal windows or console application?

What is the sample.exe designed to do? If it runs and exits without waiting for user input that is the expected behavior when you run it.

1 solution

The code is correct: it should work fine, except the backslash characters in the executable string.
Try this instead:
C#
process1.StartInfo.FileName = @"d:\work\sample.exe");
 
Share this answer
 
Comments
Member 9735370 7-Nov-15 7:11am    
sorry bro its not work that way also. i even see the application opening but its close suddenly after opening. if its run fine its open for some time like 10 sec. thats the main problem

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900