0

I am trying to execute a code from c# windows form application.

 string cmdCode = "/C mogrify -crop 590x389+116+102! D:\\Backup\\Images\\*.TIF"; System.Diagnostics.Process.Start("CMD.exe", cmdCode); 

But It doesnt do what it is supposed to do?

the code perfectly does the job when I type it in the command line. I already tried to change the path. I placed the tif files with MyApp.exe file and changed the cmdCode as

cmdCode = "/C mogrify -crop 590x389+116+102! *.TIF"; 

no success.. It shows up the black command promt very quickly and it gets disappeared.

I also tried to put the code in a file and make the extension .bat to run it but still no success!! any suggestions ?

Thanks

2 Answers 2

2

Try replacing the /C option with /K. That will not solve your problem, but it should prevent the command prompt from disappearing, and allow you to see if any error is displayed by the prompt.

It's also possible that the PATH you are passing to CMD.exe is different from the one used by default, for some reason. Once you've started cmd.exe with the /K option, you should also be able to issue a echo %PATH% command, and see what you've got.

Sign up to request clarification or add additional context in comments.

Comments

2

Remove the cmd.exe part and instead place there the path to mogrify.exe and start the parameters with "-crop...", removing the /C

If you're passing along path names that contain spaces you'll need to enclose the path with quotes, so the parameters will look like this:

"-crop \"590x389+116+102!\" \""+YourPathHere+"\"";

1 Comment

@akdurmus what's the exception?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.