## Running an EXE *with arguments*

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Kukurykus, Tom, xbytor

IanC
Posts: 6
Joined: Mon Nov 30, 2020 10:04 pm

### Running an EXE *with arguments*

I'm new to PS scripting, and really pleased with what I achieved over the weekend! Stitching a lot of map tiles together using parts of the filename to determine their position.

But I am stuck on trying to run an EXE with arguments, from within a JSX. I can do it OK without arguments.

Something such as this, although the argument will vary, which works fine at the command line:
"C:\Program Files\MAPC2MAPC64\mapc2mapc64.exe" "C:\Users\Ian\Desktop\9 SP test tiles\stitched\SP.tfw"

I have searched and tried various examples in File.Execute tutorial. I'm using Windows 10.

Kukurykus
Posts: 363
Joined: Mon Jul 25, 2016 12:36 pm

### Re: Running an EXE *with arguments*

Code: Select all

``system('start "" "C:\Program Files\MAPC2MAPC64\mapc2mapc64.exe" "C:\Users\Ian\Desktop\9 SP test tiles\stitched\SP.tfw"')``

IanC
Posts: 6
Joined: Mon Nov 30, 2020 10:04 pm

### Re: Running an EXE *with arguments*

Perfect (nearly!), I had to use double backslashes (to Escape the backslash I think?).

Using a variable for the argument, I ended up with:

Code: Select all

``````var arg = ' "C:\\Users\\Ian\\Desktop\\9 SP test tiles\\stitched\\SP.tfw"'
system('start "" "C:\\Program Files\\MAPC2MAPC64\\mapc2mapc64.exe"'+arg)``````
Many thanks!

IanC
Posts: 6
Joined: Mon Nov 30, 2020 10:04 pm

### Re: Running an EXE *with arguments*

Really weird, that was working, now doesn't seem to be....

****EDIT: Now it is (silly typo).
Last edited by IanC on Mon Nov 30, 2020 11:16 pm, edited 4 times in total.

Kukurykus
Posts: 363
Joined: Mon Jul 25, 2016 12:36 pm

### Re: Running an EXE *with arguments*

Yes, you are right, I did not test it, but wrote from memory - double backslashes are necessary

Kukurykus
Posts: 363
Joined: Mon Jul 25, 2016 12:36 pm

### Re: Running an EXE *with arguments*

Did you correct that typo in your posted code, what that was?

IanC
Posts: 6
Joined: Mon Nov 30, 2020 10:04 pm

### Re: Running an EXE *with arguments*

Nothing important, it was only one of the folder names in the argument Thanks again for your help.