1
ProcessStartInfo psi = new ProcessStartInfo();
psi.CreateNoWindow = false;
psi.UseShellExecute = false;
psi.FileName = "convert.exe";
psi.WorkingDirectory = @"C:\Users\Der\Downloads\Wunderground_API_Test\Wunderground_API_Test\Wunderground_API_Test\";
psi.Arguments = " icone.gif -fuzz 10% -transparent white icone.ico";
Process.Start(psi);

If I try to run this nothing happens but if go to that path and type convert.exe icone.gif -fuzz10% -transparent10% white icone.ico it works. What am I doing wrong?

Aman
  • 582
  • 2
  • 12
  • 29

3 Answers3

2

I gave up and did a bat file and it works.

        var p = new System.Diagnostics.Process();
        p.StartInfo.FileName = @"C:\Users\LL\Downloads\Wunderground_API_Test\Wunderground_API_Test\Wunderground_API_Test\icone.bat";
        p.StartInfo.WorkingDirectory = @"C:\Users\LL\Downloads\Wunderground_API_Test\Wunderground_API_Test\Wunderground_API_Test\";
        p.StartInfo.RedirectStandardOutput = true;
        p.StartInfo.UseShellExecute = false;
        p.StartInfo.CreateNoWindow = true;
        p.Start();
        p.WaitForExit();
Aman
  • 582
  • 2
  • 12
  • 29
1

So, trying this out on my machine in LINQPad, I think it might be a misunderstanding of a working directory. The working directory is not the location of the file, it's where the file should think it's being run from. Try removing that line and specifying the complete path in FileName. That worked for me.

Kyle W
  • 3,702
  • 20
  • 32
  • The error the OP gets is from the windows convert.exe tool that `Converts a FAT volume to NTFS.`.... – rene Jun 13 '14 at 18:29
1

This is because C# passes StartInfo parameters as Unicode and your program "convert.exe" does not handle intepretting the Unicode arguments. While calling it through a batch file the way you are doing it does not pass the parameters as Unicode.

Below link looks like addresses your issue. With code examples.

Application started by Process.Start() isn't getting arguments

Community
  • 1
  • 1
CodeCowboyOrg
  • 2,983
  • 1
  • 15
  • 12