Problem starting Process with arguments

  • Thread starter Thread starter Saso Zagoranski
  • Start date Start date
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());
 
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,
 
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!
 
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,
 
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,
 
Besides... the problem is that des is not GETTING parameters not with the
parameters itself...
 
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
 
Back
Top