


Using Windows PowerShell to run old command line tools (and theirĪs with the first problem, you can run CMD.EXE itself and pass yourĬommand and its parameters in quotes. This will return the directory listing as a string but returns much faster than a GCI #runs DIR from a cmd shell, DIR in PowerShell is an alias to GCI. That it should terminate after the command has completed.

The command and returns the text of that command. PowerShell (NOTE: This was an issue with PowerShell v2 and its use ofĭetails: Opens a CMD prompt from within powershell and then executes Times used with a DIR which runs faster in the cmd shell than in Why: Bypasses PowerShell and runs the command from a cmd shell. ** This method should no longer be used with V3 $AllArgs = '-someswitch', 'C:\documents and settings\user\desktop\some other file.txt', '-yetanotherswitch') $arg3 = 'C:\documents and settings\user\desktop\some other file.txt' In this case it is better to separate everything like so: $CMD = 'SuperApp.exe' With spaces you have to nest Quotation marks and the result it is not Or there are spaces in the arguments or paths! Things can get tricky when an external command has a lot of parameters & 'C:\Program Files\Windows Media Player\wmplayer.exe' "c:\videos\my home video.avi" /fullscreen See these details from Microsoft and others:. Please let me know if I can provide anything else?Ĭalling external exe's/cmd's via PowerShell requires specific attention. $expression = "$cbllinkExe -s -o$($outputFile) `"$($inputFile)`" adis adisinit adiskey -u`"$cobolFile`""Īnyone who might have any insight and could provide some assistance, I would very much appreciate it. I successfully have this working with CBLLINK.EXE, but it does not require as many parameters. Missing expression after unary operator ','. | At line:1 char:97 + … GQ NOQUERY noALTER noanim nobound checkdiv COMP errlist list() FASTLI … + ~Īn expression was expected after '('. $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\`", , " My attempt at converting this to Powershell has been like this: $cobolExe = ".\COBOL.EXE" 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%%", , I am currently working on reworking this in Powershell as a build script. I have the command as it was used in the original batch script. I am hoping someone might be able to help me with writing a COBOL MF Net Express 5.1 compile command in Powershell.
