Executing Windows Batch file (.bat)

Post Reply
netaware
Newbie
Posts: 19
Joined: Tue Jul 30, 2024 7:11 pm

Executing Windows Batch file (.bat)

Post by netaware »

I have a flow that is assembling a job folder consisting of 2 files and building a Windows batch file (.bat) to run from within the job folder.

I am able to get everything together, but I am having trouble running the batch file.

The batch file runs from the command prompt perfectly.

I am using the RUN command, but it is deleting the job folder. The Execute Command does not allow me to run the file dynamically.
The Execute Command Friend application documentation is outdated.

I need to preserve the job folder and output the command produces.

Does anyone have any ideas how I can do this?
User avatar
JimmyHartington
Advanced member
Posts: 460
Joined: Tue Mar 22, 2011 7:38 am

Re: Executing Windows Batch file (.bat)

Post by JimmyHartington »

Can you share your bat script? This would make it a bit easier to help troubleshoot.

I have had some flow, where I "cd" into a folder in a bat file and do the processing.
Perhaps this is possible here.
User avatar
JimmyHartington
Advanced member
Posts: 460
Joined: Tue Mar 22, 2011 7:38 am

Re: Executing Windows Batch file (.bat)

Post by JimmyHartington »

It could then look like the flow below.

2 arbitrary files are assembled into a jobfolder.
The "Run Command" app cds into the directory and runs a command to create an empty file.
This is created in the job-folder.
Royal TSX-Flow-server03-2025-06-12 at 07.39.17@2x.png
Royal TSX-Flow-server03-2025-06-12 at 07.39.17@2x.png (109.08 KiB) Viewed 843 times
netaware
Newbie
Posts: 19
Joined: Tue Jul 30, 2024 7:11 pm

Re: Executing Windows Batch file (.bat)

Post by netaware »

Hi and thank you for your help!
This is my flow. I am creating a .bat for each job using the "Create file from template" app and private data and placing that .bat in the job folder
Flow1.png
Flow1.png (43.84 KiB) Viewed 379 times
Below is the .bat file that is needed to run
Flow2.png
Flow2.png (123.59 KiB) Viewed 379 times

What i am trying to do is use Beyond Compare to compare approx. 400 text files. I can only run one at a time, but they run in 1 or 2 seconds. The flow is using the job name as the job folder name, so maybe what i can do is keep the job folder name the same, then i can use your idea to CD into it and run the .bat file, which will always be the same name.

Tell me what you think. Thank you very much
User avatar
JimmyHartington
Advanced member
Posts: 460
Joined: Tue Mar 22, 2011 7:38 am

Re: Executing Windows Batch file (.bat)

Post by JimmyHartington »

Is the order of the text files important in bat-file?

Because otherwise I think this could be done without the need to create a bat file and make the run command more universal.

If you want I could give it a crack by downloading a Beyond Compare trial and make a flow.
netaware
Newbie
Posts: 19
Joined: Tue Jul 30, 2024 7:11 pm

Re: Executing Windows Batch file (.bat)

Post by netaware »

Yes the order is important because you have to compare the original to the newer version of the file.
But I did change things with the RUN command.

I am trying to run the commandline without a batch file and had some success. This is the what i am doing with the RUN command:

"C:\Program Files\Beyond Compare 4\BCompare.exe" @D:\Testing\BC4\MISC\BC-MAG_COMPARE.txt "[Job.Path]\[Job.PrivateData:Key="Before"]" "[Job.Path]\[Job.PrivateData:Key="After"]" "[Job.Path]\outhtml"

It kinda worked. The compare ran successfully, i think the RUN command it deleting the job folder. BC4 produces a log file and that is the only left after the RUN command and the outgoing folder.
Flow3.png
Flow3.png (6.6 KiB) Viewed 371 times
User avatar
JimmyHartington
Advanced member
Posts: 460
Joined: Tue Mar 22, 2011 7:38 am

Re: Executing Windows Batch file (.bat)

Post by JimmyHartington »

Try changing the command to this:

Code: Select all

cd "%%InputFilePath%%" && "C:\Program Files\Beyond Compare 4\BCompare.exe" @D:\Testing\BC4\MISC\BC-MAG_COMPARE.txt "[Job.PrivateData:Key="Before"]" "[Job.PrivateData:Key="After"]" "out.html"
This way the command should go into the job folder. Then you can reference the filenames as you do with Private Data Key "Before" and "After".
And the "out.html" should be created in the job folder.

Are the Private Data Key "Before" and "After" set correctly earlier in the flow?
sophia05
Newbie
Posts: 1
Joined: Sat Jun 21, 2025 6:08 am
Contact:

Re: Executing Windows Batch file (.bat)

Post by sophia05 »

Have you tried running the batch file through an intermediate script (e.g. PowerShell or VBScript) to control the execution environment? I'm wondering if the RUN environment itself is doing a cleanup after it finishes without preserving the job folder?
netaware
Newbie
Posts: 19
Joined: Tue Jul 30, 2024 7:11 pm

Re: Executing Windows Batch file (.bat)

Post by netaware »

Hello,
I got it working.
Ended up using the app "Create File From Template" and built my batch file with it.

First I make a copy of the job folder, then run the batch file, it send output to the BC4_temp folder. The "Run Command" sends the job folder on to "Folder 12", why I do not know, but this works for me.
Flow4.png
Flow4.png (28.75 KiB) Viewed 85 times
Thank you for your help!
User avatar
JimmyHartington
Advanced member
Posts: 460
Joined: Tue Mar 22, 2011 7:38 am

Re: Executing Windows Batch file (.bat)

Post by JimmyHartington »

Glad you got it to work.
Post Reply