我们可以从powershell运行FME吗?

我们可以从powershell运行FME吗?,powershell,fme,Powershell,Fme,我想从PowerShell.ps1one运行FME.fmw文件。 我知道我可以用命令fme C:\Path\of\fmw 但是我没有找到一种方法来使用PowerShell。 启动流程将仅打开FME,而不会启动它 $repertory_source = Read-Host "Path of file ? (X:\X\X.fmw)" start-process -FilePath $repertory_source 我想运行FME.fmw,而无需打开FME工作台有一种直接的方法可以调用fmw文件并

我想从
PowerShell.ps1
one运行
FME.fmw
文件。 我知道我可以用命令
fme C:\Path\of\fmw
但是我没有找到一种方法来使用
PowerShell
。 启动流程将仅打开
FME
,而不会启动它

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

我想运行
FME.fmw
,而无需打开
FME工作台

有一种直接的方法可以调用fmw文件并相应地传递参数。请参阅下面的完整详细信息

可以从Windows中的命令行运行FME:打开命令提示符窗口并键入FME将显示下面显示的完整选项列表

FME.fmw命令将运行特定的工作区。因此,如果可以从命令行调用FME工作区,则可以从DOS批处理(.bat)文件调用一系列工作区(或具有不同数据集的同一工作区)

用法

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:
fme[]*[-]*
fme[*]
fme,fmelic

fme

允许用户手动输入可能更长的路径容易出错,对用户不友好

我建议使用预先设置了文件类型和起始目录的OpenFileDialog

## 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}
}

运行fme可执行文件并将fmw文件作为参数提供
## 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}
}