Skip to main content

I have a simple workbench that reads a postgis database and outputs an excel file based on a user parameter in which the user enters a filename that filters the input table into one record. This works fine within FME, however I'd like to create a batch file that runs the workbench from the command line. The problem I have is getting the batch file to prompt for the user parameter. It just runs the workbench with the last parameter I set within FME. I'd like to be able to run the batch file and get the prompt for the parameter in the command line.

Hi @ajc​ ,

If you open the .fmw file in a text editor, the first few lines will have the command line to use in the batch file, with the parameters prefaced by '--'. You can change the parameter values on the command line in the batch file, but FME will not prompt for them.

 If you want to prompt for the parameters before running the workspace, you could try running fmequicktranslator.exe test.fmw from the command line. This will run the Quick Translator, which will prompt and run the workspace, but offers no editing capability.


@ajc​ The question is more a Windows command line problem, rather than an FME problem, but to break it down:

  1. First expose the Parameters you want to potentially vary in the WorkBench Workflow by creating them as "Published Parameters" in the User Parameters list. This makes them available to change in the command line interface for FME.EXE as they then become exposed arguments (and you will see them become visible in the top of the Translation Log where it shows you the BAT command line to run with "Command-line to run this workspace: "C:\Program Files\FME\fme.exe ...." 
  2. Then you just need to substitute the fixed default parameter values with Command Line variables. So edit the BAT text commands so that instead of Eg. "C:\Program Files\FME\fme.exe C:\RiverRun.SHP" , you change this to "C:\Program Files\FME\fme.exe %ParameterValue1%" Anything between %....% is the Windows way of saying that this is a variable, and not a literal string (and another Windows Tips and Tricks is this is also how you can access the values of System and Environment Variables Eg. Knowing that typing %TEMP% or %APPDATA% in Windows Explorer gets you to the declared Temp or Application Data Folder in the Environment variables is a nice shortcut)
  3. So now all you need is the first lines in the BAT file to prompt the user first for the value of %ParameterValue1% by using the "SET /P" command. So the final BAT text file looks a bit like this
@echo on
 SET /P ParameterValue1="Please Enter Parameter 1 Value: "
 ECHO You Entered %ParameterValue1% as the Value
"C:\Program Files\FME\fme.exe %ParameterValue1%"

This is the bare bones approach in any case, there are likely numerous utilities that could be used to wrap the Command Shell into a nicer Windows GUI, but for a CLI level interface, variations of the above will do the trick.


Reply