Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
Dear ImageJ mailing list.
I would like to execute two lines of Windows cmd commands within the macro language. Specifically, I want to execute the following two commands... cd C:Program Files\ImageJ\plugins\CHT Clinical Programs\DICOM Export storescu -v 10.139.228.187 104 C:\_Temp\SecondaryCapture.dcm -aec XELERIS3 At the moment I am executing these commands with a .bat file that sits on my desktop but it would be great if I could do this within the macro language. There must be a way of doing this using the built-in in macro function... exec(string or strings)... but I'm struggling. Can anybody help? Thanks, Greg (Birmingham, UK) -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
On Thursday, 26 October 2017 12:25:09 BST Gregory James wrote:
> I would like to execute two lines of Windows cmd commands within the macro > language. > > Specifically, I want to execute the following two commands... > > cd C:Program Files\ImageJ\plugins\CHT Clinical Programs\DICOM Export > storescu -v 10.139.228.187 104 C:\_Temp\SecondaryCapture.dcm -aec XELERIS3 > > At the moment I am executing these commands with a .bat file that sits on my > desktop but it would be great if I could do this within the macro language. Have a look in the Macro Functions pages: exec(string or strings) Executes a native command and returns the output of that command as a string. Also opens Web pages in the default browser and documents in other applications (e.g., Excel). With commands with multiple arguments, each argument should be passed as a separate string. For example exec("open", "/Users/wayne/test.jpg", "-a", "/Applications/Gimp.app"); Refer to the ExecExamples macro for examples. Hope it helps. Gabriel -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
In reply to this post by JAMES,
gregory (SANDWELL AND WEST BIRMINGHAM HOSPITALS NHS TRUST)
Thank you to all the people that replied to me publicly and privately.
I have sorted my problem so will post the solution to the ImageJ community... The command required is indeed... exec("cmd", "/c", "start", path); ... where 'path' is the path to the .bat file that you want to execute. In the Windows cmd command prompt, the path is allowed to have spaces in it, but it seems (at least for my version of ImageJ) that the path is *NOT* allowed to have any spaces in it in the macro language. I find this slightly strange as I've not had this problem before. My experience is that ImageJ tends to be happy with spaces in string file paths. Perhaps someone more knowledgeable than myself could enlighten the community and explain what is happening here? Thanks, Greg (Birmingham, UK) -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
You are trying to use the Windows start command.
That needs its parameters to be enclosed with hyphens. The syntax is start "Window Title" "C:\path to folder\path to file" You need to escape the commands properly to get the hyphens and backslashes correctly. In ImageJ this would be something like exec("cmd", "/c", "start", "\"Window Title\"", "\"C:\\path to folder\\path to file\""); You need to do a few trials and errors to get this right. Forward slashes instead of backslashes usually work and do not need escaping. And - are you sure you need to use the windows start command? That is normally used when you want to start something and NOT wait for it to complete. That is probably not what you want in an image processing workflow. Try instead exec("cmd", "/c", "\"C:\\path to folder\\path to file\""); if the file you want to open is already openable on the Windows commandline, or just exec("\"C:\\path to folder\\path to file\""); if your file is an executable that can run by itself. With parameters, e.g. to run a script: exec("\"C:\\path to scripting language\\program.exe\"", "\"C:\\path to some folder\\file containing script\""); Hope this helps. Stein -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Gregory James Sent: 27. oktober 2017 10:57 To: [hidden email] Subject: Re: Execute Windows cmd commands within macro language Thank you to all the people that replied to me publicly and privately. I have sorted my problem so will post the solution to the ImageJ community... The command required is indeed... exec("cmd", "/c", "start", path); ... where 'path' is the path to the .bat file that you want to execute. In the Windows cmd command prompt, the path is allowed to have spaces in it, but it seems (at least for my version of ImageJ) that the path is *NOT* allowed to have any spaces in it in the macro language. I find this slightly strange as I've not had this problem before. My experience is that ImageJ tends to be happy with spaces in string file paths. Perhaps someone more knowledgeable than myself could enlighten the community and explain what is happening here? Thanks, Greg (Birmingham, UK) -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Disable Popup Ads | Edit this page |