473,324 Members | 2,313 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

programmatically executing command line c#

15
Hi,
I am using .net Process class to run an executable process , say abc.exe which takes three parameters- two input files(file1 & file2)
and one output file(file3).Based on the two input files, the o/p file3 is to be updated.
The command line on the console will look like this:
C:\dir\...> abc.exe file1 file2 -o file3

On my c# code, I am doing something like:

Process myProc = new Process();
myProc.StartInfo.Filename = "dir\abc.exe";
myProc.StartInfo.Arguments = "file1, file2, file3";
myProc.Start();

It executes without giving any errors, but my o/p file3 is not updated.
I am trying to figure out where I might have gone wrong to run this process.
Or is there any other way to execute programatically the exe file?
Please help!
Thanks!
Feb 27 '08 #1
3 7261
Plater
7,872 Expert 4TB
If your program is launched like this:
Expand|Select|Wrap|Line Numbers
  1. C:\dir\...> abc.exe file1 file2 -o file3
  2.  
Why are you doing this:
Expand|Select|Wrap|Line Numbers
  1. myProc.StartInfo.Filename = "dir\abc.exe";
  2. myProc.StartInfo.Arguments = "file1, file2, file3";
  3.  
Shouldn't you be doing this?
Expand|Select|Wrap|Line Numbers
  1. myProc.StartInfo.Filename = "dir\abc.exe";
  2. myProc.StartInfo.Arguments = "file1 file2 -o file3";
  3.  
Feb 27 '08 #2
MedIt
15
If your program is launched like this:
Expand|Select|Wrap|Line Numbers
  1. C:\dir\...> abc.exe file1 file2 -o file3
  2.  
Why are you doing this:
Expand|Select|Wrap|Line Numbers
  1. myProc.StartInfo.Filename = "dir\abc.exe";
  2. myProc.StartInfo.Arguments = "file1, file2, file3";
  3.  
Shouldn't you be doing this?
Expand|Select|Wrap|Line Numbers
  1. myProc.StartInfo.Filename = "dir\abc.exe";
  2. myProc.StartInfo.Arguments = "file1 file2 -o file3";
  3.  
Sorry, thats my mistake:
in my code it is actually:
myProc.StartInfo.Arguments = "file1 file2 -o file3"

Still no effect!
Feb 27 '08 #3
Plater
7,872 Expert 4TB
What if you put:
Expand|Select|Wrap|Line Numbers
  1. myProc.StartInfo.Arguments = @"file1 file2 -o c:\file3";
  2.  
Does the file at c:\file3 get created? It might be making that file somewhere other then where you think it should?
Feb 27 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Falk Schneider | last post by:
I wrote a PHP shell script under Linux which puts all existing PS-Files within a directory into a list and should then start a single Ghostview window for each file. Sounds simple, but it's not: ...
0
by: Nick Coghlan | last post by:
Anyone playing with the CPython interpreter's new command line switch might have noticed that it only works with top-level modules (i.e. scripts that are directly on sys.path). If the script is...
15
by: Nick Coghlan | last post by:
Python 2.4's -m command line switch only works for modules directly on sys.path. Trying to use it with modules inside packages will fail with a "Module not found" error. This PEP aims to fix that...
0
by: andrea valle | last post by:
Hi to all, I need to run a program from inside python (substantially, algorithmic batch processing). I'm on mac osx 10.3.8 with python 2.3 framework and macpython. Trying to use exec*, I...
18
by: Brad Pears | last post by:
Can someone give me some sample code on how one would go about executing a command line "command" from within an ASP form? We need to run an application called GnuPG which allows us to encrypt an...
15
by: (Pete Cresswell) | last post by:
I've got a .BAT file that I use for executing various MS Access apps that I wrote way back in the days of 2.0. It's evolved over time, but it still contains a number of possible paths to...
5
by: Bryan | last post by:
I am writing a C# program that needs to see if a particular program is installed (it would be listed in the "Add or Remove Programs" list from the Control Panel) and uninstall it. Is there a way...
2
by: Mike W | last post by:
I'm trying to programmatically run msinfo32.exe /? with the following line of code but it is not taking the switch: System.Diagnostics.Process.Start("c:\program files\common files\Microsoft...
1
by: Rune Jacobsen | last post by:
Hi, I've been trying to figure this one out, but my experience just doesn't have what it takes... :| I am writing an application that reads an XML file and displays the contents in various...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.