Problem starting Process with arguments

S

Saso Zagoranski

Hi!

I'm trying to run a decryption utility (des), which needs the following
parameters:
-D-u -k "key" input.file output.file

If I run this from the command-prompt it works but when I try to run it from
my application (it's a .NET service
but I've also tried running it from a Windows Application) it doesn't work.
The output from StandardError look like the ouput, if I just type "des" in
the command-prompt (it lists
all the possible arguments).

My guess is that something is wrong with the passing of parameters... any
ideas?

Thanks,
saso

The code:
string decName = @"request.dec";

string path = @"request.out.20050222";


Process myProcess = new Process();

ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(@"C:\des.exe" );

myProcessStartInfo.UseShellExecute = false;

myProcessStartInfo.CreateNoWindow = true;

myProcessStartInfo.Arguments = "-D -u -k \"myKey\" request.out.20050222";

myProcessStartInfo.RedirectStandardError = true;

myProcess.StartInfo = myProcessStartInfo;

myProcess.Start();

myProcess.WaitForExit();

StreamReader sr = myProcess.StandardError;

MessageBox.Show(sr.ReadToEnd());
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Post the code where you init the Process instance,

IF the des program is in a network drive you will have a problem with that.
Try to use the full path to the des.exe
Does des.exe use any environment variables? they may not be accesible from
the service

cheers,
 
S

Saso Zagoranski

All of the code is there...

des.exe is not on a network drive. The full path is C:\des.exe (as used in
the example below).
The program runs (because I get output from Standard Error) but I doesn't
accept parameters!
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi Saso,

Sorry for that, I did not check below the signature , too early in the
morning probably :)

Why don't you try to use the full path name for both the source & target
files?

cheers,
 
S

Saso Zagoranski

it's the same...

Ignacio Machin ( .NET/ C# MVP ) said:
Hi Saso,

Sorry for that, I did not check below the signature , too early in the
morning probably :)

Why don't you try to use the full path name for both the source & target
files?

cheers,
 
S

Saso Zagoranski

Besides... the problem is that des is not GETTING parameters not with the
parameters itself...
 
C

CometJoe

Howdy,

In your line...

myProcessStartInfo.Arguments = "-D -u -k
\"myKey\"
request.out.20050222";


insert a whitespace before the "-D"... I pass the following to
"osql.exe" and it works. I think that the space is required to
separate the execuatable name from the arguments. Or try typing in
the command window "des.exe-D..." without a space and I think it will
fail the same.

[code:1:5fae666b70]prcDB.StartInfo.Arguments = " -E -icope.sql
-o" + m_strInstallPath + "\\copedb.log";
[/code:1:5fae666b70]

HTH,
Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top