在Powershell中编译Micro Focus Net Express 5.1 Cobol
我希望有人能帮助我在Powershell中编写COBOL MF Net Express 5.1编译命令。我拥有原始批处理脚本中使用的命令。我目前正在Powershell中将其作为构建脚本进行修改在Powershell中编译Micro Focus Net Express 5.1 Cobol,powershell,cobol,Powershell,Cobol,我希望有人能帮助我在Powershell中编写COBOL MF Net Express 5.1编译命令。我拥有原始批处理脚本中使用的命令。我目前正在Powershell中将其作为构建脚本进行修改 COBOL.EXE "%%inFile%%" OUTDD NOERRQ NOFLAGQ NOQUERY noALTER noanim nobound checkdiv COMP errlist list() FASTLINK omf"gnt" perform-type"osvs" SCHEDULER T
COBOL.EXE "%%inFile%%" OUTDD NOERRQ NOFLAGQ NOQUERY noALTER noanim nobound checkdiv COMP errlist list() FASTLINK omf"gnt" perform-type"osvs" SCHEDULER TARGET"PENTIUM" noTRUNC vsc2(1) listpath"","%%OUTPUT%%";,;,;
我尝试将其转换为Powershell,如下所示:
$cobolExe = ".\COBOL.EXE"
$expression = "& $cobolExe `"$($inputfile)`" OUTDD NOERRQ NOFLAGQ NOQUERY noALTER noanim nobound checkdiv COMP errlist list() FASTLINK omf`"gnt`" perform-type`"osvs`" SCHEDULER TARGET`"PENTIUM`" noTRUNC vsc2(1) listpath`"`", `"$binPath\`";,;,;"
Invoke-Expression $expression
Invoke-Expression:
Line |
1 | Invoke-Expression $expression
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| At line:1 char:97 + … GQ NOQUERY noALTER noanim nobound checkdiv COMP errlist list() FASTLI … + ~
An expression was expected after '('. At line:1
| char:221 + … NTIUM" noTRUNC vsc2(1) listpath"", "C:\dev\dimensions\test\bin\";,;,; + ~
Missing expression after unary operator ','. At line:1
| char:223 + … NTIUM" noTRUNC vsc2(1) listpath"", "C:\dev\dimensions\test\bin\";,;,; + ~
Missing expression after unary operator ','.
我成功地将其与CBLLINK.EXE一起使用,但它不需要那么多参数
$cobolFile = "$Path\cobol.dir"
$cbllinkExe = ".\CBLLINK.EXE"
$expression = "$cbllinkExe -s -o$($outputFile) `"$($inputFile)`" adis adisinit adiskey -u`"$cobolFile`""
Invoke-Expression $expression
任何有见识并能提供帮助的人,我都非常感谢。请告诉我是否可以提供其他信息?通过PowerShell调用外部exe/cmd需要特别注意。这是一件有据可查的事情 从Microsoft和其他网站查看这些详细信息:——
CMD.EXE/C“ICACLS.EXE C:测试/授予用户:(F)”
…还有更多类似的功能。通过PowerShell调用外部exe/cmd需要特别注意。这是一件有据可查的事情。查看Microsoft和其他公司提供的这些详细信息:---还有更多类似的信息。谢谢!CMD/C满足了我的需要。不用担心,我会将此评论移至答案部分,以便您可以将其标记为您接受的答案,以方便其他可能遇到此问题的人。
# Example:
& 'C:\Program Files\Windows Media Player\wmplayer.exe' "c:\videos\my home video.avi" /fullscreen
$CMD = 'SuperApp.exe'
$arg1 = 'filename1'
$arg2 = '-someswitch'
$arg3 = 'C:\documents and settings\user\desktop\some other file.txt'
$arg4 = '-yetanotherswitch'
& $CMD $arg1 $arg2 $arg3 $arg4
# or same like that:
$AllArgs = @('filename1', '-someswitch', 'C:\documents and settings\user\desktop\some other file.txt', '-yetanotherswitch')
& 'SuperApp.exe' $AllArgs
# Example:
#runs DIR from a cmd shell, DIR in PowerShell is an alias to GCI. This will return the directory listing as a string but returns much faster than a GCI
cmd /c dir c:\windows
CMD.EXE /C "ICACLS.EXE C:TEST /GRANT USERS:(F)"
<#
# Results
processed file: C:TEST
Successfully processed 1 files; Failed processing 0 files
#>