Command line arguments for application favorites

Started by Arthur, December 20, 2017, 01:30:45 PM

Previous topic - Next topic

Arthur

Hi,

I am using DxO for raw development, which is executed from inside IM via application favorite shortcut. The DxO exe supports several modes which are passed as command line arguments, like that:

1) DxO.PhotoLab.exe -mode=openwith <file list>
2) DxO.PhotoLab.exe <file list>
3) DxO.PhotoLab.exe -mode=lightroom <file list>

After installation the Desktop shortcut is configured like in 1). After I drag this shortcut into IM Application favorites and use it, it looks like 2) is executed. So the command line arguments are lost. Would it be hard to preserve the command line arguments after drag droping the desktop shortcut into the application favorites or would it be possible to offer a field for command line arguments in the application favorite tile properties?

Mario

#1
IMatch has no idea about how the shortcut you drop as a Favorite is configured. IMatch just records the name, and  later launches the shortcut via the file name, providing Windows with the list of selected file names via the standard protocol - simulating a file drop on the shortcut. IMatch neither knows which target (application) the shortcut starts or which options are configured. This is a black box.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Arthur

Hm, interesting that the command arguments are lost then. Have to investigate this, maybe the problem is in PhotoLab, when there is a master application which starts the process.

Mario

#3
Perhaps when running a shortcut via dropping files the command line arguments no longer apply. The drop method was the only reliably method I could find that worked across all Windows platforms and versions, from W7 to Server 2016. Launching a shorcut is one thing, providing files is a totally different beast.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Arthur

If it is lost, maybe it would help people to define an explicit command line argument string in IM which is appended before the file list, like that:

START MyTool.lnk <my arguments> <file list>

But as long as there is no demand for this from others, I think I will write a proxy app, which receives the plain file list from IMatch and forwards it to PhotoLab with a configured argument set.


Mario

This can't be done. The Windows functions I use allow me to "run" a shortcut and to provide the drop arguments. There is no interface for specifying command line arguments. IMatch is not running a command line here. This would not allow to deal with file name lists. If you need something special, write a small app which uses the ShellExecute endpoint to launch DxO. Here you can specify your own command line arguments and produce a list of file names and append them to the command line.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Arthur

#6
Yes, I meant that by writing a proxy app. I only need to choose the right method to start the DxO process, because some methods allow only short command line argument lengths up to 8192 characters. IMatch supports up to 32767 and I must ensure that these are not truncated. Something which is based on the "CreateProcess" API call. ShellExecute seems to support only 2048.

Mario

Command lines are designed to handle things like /s/e or maybe a folder or file name. Not for bulk transfers of large lists of file names. Windows API functions like ShellExecute etc. limit the maximum command line length. See MSDN for precise limits. If you need to hand over so many file names that you exceed 2K, you may think about different ways.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Arthur

#8
The filenames from IMatch are also passed (internally on OS level) as a command line arguments list. I have written a small c# program to read out what comes in as command line arguments in my "Main" method on application shortcut execution in the favorites inside IMatch.

IMatch -> Application Shortcut -> lnk -> TestApp

Here I get C:\...\MyFile1.CR2 ... C:\...\MyFileN.CR2 as command line arguments.

I have also tested the max length. After selecting about 690 files with a path length of about 50 characters each and executing the application favorite, I also get a message in IMatch, that this is not possible.

So basically it is all converted to some sort of command line arguments. Only the max allowed length differs.

ubacher

Here a snippet of code where I call dngconverter with arguments. Maybe it is of help.
I have not run into problems re length of files-argument but I probably never had more than a few hundred.
for (var x = 0; x < rawfiles.length; x++) {
                        catenFiles = catenFiles + '"' + rawfiles[x].fileName + '" ';
                    }

                    IMatch.shellExecute({
                        'verb': 'open',
                        'parameters': "-p2 -fl -lossy -cr7.1 " + catenFiles,
                        'executable': 'C:\\Program Files (x86)\\Adobe\\Adobe DNG Converter.exe',
                       
                    }).then(function (response) {



Arthur

Thx, but I am too old for JavaScript. 😁 Do not like this JSON like key value style of programming. Will stay with .NET/C#/Visual Studio.

tmcgill

This is an old thread, but still one which pops up in response to searches on the topic, so I thought I'd mention a method of accomplishing this in case anyone finds it useful. I have Adobe DNG Converter set up to run with a particular parameter set on only the selected files. Other applications (e.g., DxO.PhotoLab.exe as mentioned originally) could likely work as well, using the following method:

1) I created a 4-line batch file which runs the desired exe file with my own preferred parameters followed by all the arguments passed into the batch file:
@echo off
echo Starting conversion...
"C:\Program Files (x86)\Adobe\Adobe DNG Converter" -p2 %*
echo Done.
pause


2) Alt-dragged the batch file right next to itself into the same folder to create a shortcut to it. Renamed that shortcut to whatever I wanted my favorite called. (Bonus step: right-click on the shortcut, hit the "Change Icon" button, then browse to find the exe for the application you are running, and choose an icon from that file. It will then be the icon used by the shortcut and thus also shown in the IMatch favorites list.)

3) Dragged the shortcut into the IMatch application favorites (you can't drag and drop the batch file itself there, thus step #2 above).

Very simple solution, as long as I don't have enough files selected at once to exceed the Windows command line length limit. That limit (8192 characters) can certainly be hit easily, because we are talking about passing filenames with full paths. But the saving grace: I can tell whether the job was in fact run or not, because A) With an enormous number of files selected at once, IMatch itself will give me an error and refuse to launch the favorite; and B) With a lesser but still too-large number of files, the batch file looks like it launches, but then disappears immediately without doing anything...hence my beginning the batch file with a "Starting conversion..." and the "pause" line at the end. So if I get a window up telling me that the conversion is running, I know it actually is; and when it finishes, it waits for me to acknowledge that. If the window instead disappears by itself, I know I had too many files selected at once and have to try it in smaller batches.

It isn't perfect, but it is simpler than the C#-based solution that I almost went and built before trying this out first and finding it to be adequate for the immediate task I needed.

Mario

-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Jingo

Quote from: tmcgill on July 25, 2019, 04:50:50 AM
This is an old thread, but still one which pops up in response to searches on the topic, so I thought I'd mention a method of accomplishing this in case anyone finds it useful. I have Adobe DNG Converter set up to run with a particular parameter set on only the selected files. Other applications (e.g., DxO.PhotoLab.exe as mentioned originally) could likely work as well, using the following method:

1) I created a 4-line batch file which runs the desired exe file with my own preferred parameters followed by all the arguments passed into the batch file:
@echo off
echo Starting conversion...
"C:\Program Files (x86)\Adobe\Adobe DNG Converter" -p2 %*
echo Done.
pause


2) Alt-dragged the batch file right next to itself into the same folder to create a shortcut to it. Renamed that shortcut to whatever I wanted my favorite called. (Bonus step: right-click on the shortcut, hit the "Change Icon" button, then browse to find the exe for the application you are running, and choose an icon from that file. It will then be the icon used by the shortcut and thus also shown in the IMatch favorites list.)

3) Dragged the shortcut into the IMatch application favorites (you can't drag and drop the batch file itself there, thus step #2 above).

Very simple solution, as long as I don't have enough files selected at once to exceed the Windows command line length limit. That limit (8192 characters) can certainly be hit easily, because we are talking about passing filenames with full paths. But the saving grace: I can tell whether the job was in fact run or not, because A) With an enormous number of files selected at once, IMatch itself will give me an error and refuse to launch the favorite; and B) With a lesser but still too-large number of files, the batch file looks like it launches, but then disappears immediately without doing anything...hence my beginning the batch file with a "Starting conversion..." and the "pause" line at the end. So if I get a window up telling me that the conversion is running, I know it actually is; and when it finishes, it waits for me to acknowledge that. If the window instead disappears by itself, I know I had too many files selected at once and have to try it in smaller batches.

It isn't perfect, but it is simpler than the C#-based solution that I almost went and built before trying this out first and finding it to be adequate for the immediate task I needed.

Sounds like the perfect situation for APP to handle ..... parse the filenames, calculate the total length and break the single command into multiple executions... :-)