Executing a program with arguments
-
Hello, I am trying launching an application telling it to open a document. I build a command line surrounding the program name and each document with quotes and then use ShellExec to process. This works fine with all applications except old Adobe programs (like PhotoDeluxe or Photoshop LE). So I tried CreateProcess instead it does not work either. Tried ShellExecuteEx same error: the program does not find the document. If I take the command line I am builing and paste it in a Command Prompt it works. Other programs are able to run the application passing it a file to open. So my question is: what other way can I use to run that application telling it to open an application... Should I revert to _exec or is there something else? Regards, Nicolas
-
Hello, I am trying launching an application telling it to open a document. I build a command line surrounding the program name and each document with quotes and then use ShellExec to process. This works fine with all applications except old Adobe programs (like PhotoDeluxe or Photoshop LE). So I tried CreateProcess instead it does not work either. Tried ShellExecuteEx same error: the program does not find the document. If I take the command line I am builing and paste it in a Command Prompt it works. Other programs are able to run the application passing it a file to open. So my question is: what other way can I use to run that application telling it to open an application... Should I revert to _exec or is there something else? Regards, Nicolas
What does the code snippet look like that tries to launch Adobe and its command-line arguments?
Five birds are sitting on a fence. Three of them decide to fly off. How many are left?
-
What does the code snippet look like that tries to launch Adobe and its command-line arguments?
Five birds are sitting on a fence. Three of them decide to fly off. How many are left?
Something like this:
// build arguments string fnames; list sel = GetSelection(); for (list::iterator it = sel.begin(); it != sel.end(); ++it) fnames += "\"" + *it + "\" "; // quotes strEditor = "\"" + strEditor + "\""; strDir= "\"" + strDir+ "\""; // run the app ShellExecute(NULL, "open", strEditor.c_str(), fnames.c_str(), strDir.c_str());
This works with latest version of Photoshop for instance (6 and later) and Paint Shop Pro but NOT with Photoshop LE 5 and Photoshop Deluxe. CreateProcess and ShellExecuteEx fail the same way: the app is correctly launched but it can't find the files I am passing. Regards, Nicolas -
Something like this:
// build arguments string fnames; list sel = GetSelection(); for (list::iterator it = sel.begin(); it != sel.end(); ++it) fnames += "\"" + *it + "\" "; // quotes strEditor = "\"" + strEditor + "\""; strDir= "\"" + strDir+ "\""; // run the app ShellExecute(NULL, "open", strEditor.c_str(), fnames.c_str(), strDir.c_str());
This works with latest version of Photoshop for instance (6 and later) and Paint Shop Pro but NOT with Photoshop LE 5 and Photoshop Deluxe. CreateProcess and ShellExecuteEx fail the same way: the app is correctly launched but it can't find the files I am passing. Regards, NicolasHave you tried calling
ShellExecute()
with string constants instead of variables? This will tell you if the variables are incorrect.ShellExecute(NULL, "open", "c:\\program files\\adobe.exe", "file1 c:\\somepath\\file2 file3", "c:\\somedir", ...);
Five birds are sitting on a fence. Three of them decide to fly off. How many are left?
-
Have you tried calling
ShellExecute()
with string constants instead of variables? This will tell you if the variables are incorrect.ShellExecute(NULL, "open", "c:\\program files\\adobe.exe", "file1 c:\\somepath\\file2 file3", "c:\\somedir", ...);
Five birds are sitting on a fence. Three of them decide to fly off. How many are left?
David, thanks for suggesting. The problem came from the trailing whitespace at the end of fnames. I removed it and it workls! Thanks again, Nicolas
-
Have you tried calling
ShellExecute()
with string constants instead of variables? This will tell you if the variables are incorrect.ShellExecute(NULL, "open", "c:\\program files\\adobe.exe", "file1 c:\\somepath\\file2 file3", "c:\\somedir", ...);
Five birds are sitting on a fence. Three of them decide to fly off. How many are left?