-1

I want to run an FME.fmw file from a PowerShell.ps1 one. I know that I can do that from a batch with the command fme C:\Path\of\fmw but I do not find a way to do it with PowerShell. Start-Process will only open FME and not launch it

$repertory_source = Read-Host "Path of file ? (X:\X\X.fmw)"
start-process -FilePath $repertory_source

I want to run the FME.fmw with no need to open the FME workbench.

Andrei Fiordean
  • 223
  • 3
  • 14
Rhon Yz
  • 145
  • 1
  • 1
  • 8

2 Answers2

0

There is a direct way of calling FMW file and passing the arguments accordingly. See below the complete details.

FME can be run from the command line in Windows: Opening the Command Prompt window and typing FME gives the full list of options displayed below.

The command FME .fmw will run a particular workspace. Therefore, if FME workspaces can be called from the command line, a series of workspaces (or the same workspace with differing datasets) can be called from a DOS batch (.bat) file.

Usage

fme <controlFile> [<keyword> <value>]* [--<macroName> <value>]*
fme <scriptfile> [<scriptArgument>*]
fme <licenseFile>.fmelic
fme <command> <arguments>
where:
<controlFile> is one of <mappingFile>.fme or <workspace>.fmw
<scriptFile> is one of <tclScript>.tcl or <pythonScript>.py
<command> is one of:

Command Name Arguments


GENERATE <sourceType> <destType> <sourceDataset> <controlFile> [<keyword> <value>]*
PARAMETER_FILE <parameterFile>
COMMAND_FILE <commandFile>
REGISTER_SOCKET <hostName> <service> [serverConfigFile] [-<ServerParmName> <ServerParmValue>]*
CREATE_SOCKET <service> [serverConfigFile] [-<ServerParmName> <ServerParmValue>]*
GENTRANS [<keyword> <value>]* <parameterFile>
GENTRANS [<keyword> <value>]* <sourceType> <sourceDataset> <destType> <destDataset>
LIST_TRANSFORMERS [VERBOSE]
LIST_UNLICENSED_TRANSFORMERS
LIST_FACTORIES
LIST_FUNCTIONS
PROTECT <sourceFile> <destFile>

Reference Link Batch Processing Method

Ranadip Dutta
  • 8,857
  • 3
  • 29
  • 45
0

Letting users manually enter a possibly longer path is IMO error-prone and NOT user friendly.

I suggest to use the OpenFileDialog preequipped with file type(s) and starting directory.

## Q:\Test\2019\04\26\SO_55862942.ps1

Function Get-FileName($StartHere=[Environment]::GetFolderPath("MyDocuments")){
    Add-Type -AssemblyName System.Windows.Forms
    $OFD = New-Object System.Windows.Forms.OpenFileDialog
    $OFD.Title = "Please select fme file"
    $OFD.InitialDirectory = $StartHere
    $OFD.Filter = "fme workspace files (*.fmw)|*.fmw|fme parameter files (*.par)|*.par|All files (*.*)|*.*"
    $OFD.Multiselect = $False
    $OFD.ShowDialog() | Out-Null

    Get-Item $OFD.FileName
}

$FME = "C:\Program Files\fme\fme.exe"

$SelectedFile = Get-FileName  # -StartHere X\Path\  # optionally pass another Starting Directory

switch ($SelectedFile.Extension) {
    '.fmw' {& $FME "$($SelectedFile.FullName";Break}
    '.par' {& $FME PARAMETER_FILE "$($SelectedFile.FullName";Break}
    default {pause "[$_] Select a valid fme file, press enter to continue";break}
}