Running a network located exe using powershell from a batch file
Posted on 2012-08-17
Right, what I need doing is to run this command exactly...
\\PUMA\RMCOBOLV12\RUNCOBOL.EXE CAR001 K L=\\PUMA\RMCOBOLV12\WOWRT.DLL C=PRT.CFG
but with the working directory being
I need to write this command and its working directory into a .ps1 file, which will be called up by a batch file (the reason why is a long story!). I've placed the .ps1 file into C:\Program Files (x86)\CarPlan
My .ps1 file at the minute is...
start-process -filepath "\\PUMA\RMCOBOLV12\RUNCOBOL.EXE CAR001 K L=\\PUMA\RMCOBOLV12\WOWRT.DLL C=PRT.CFG" -workingdirectory "\\PUMA\CARPLAN\CARPLANLIVE"
and my batch file at the minute is...
powershell.exe -File "C:\Program Files (x86)\Puma CarPlan\Puma CarPlan.ps1"
I'm a complete beginner to powershell. I figure it's something to do with the "-filepath" switch because what it isn't just a file path is it, it a whole command, with switches and the like. This is what I get...
Start-Process : This command cannot be executed due to the error: The system ca
nnot find the file specified.
At C:\Program Files (x86)\Puma CarPlan\Puma CarPlan.ps1:1 char:14
+ start-process <<<< -filepath "\\PUMA\RMCOBOLV12\RUNCOBOL.EXE CAR001 K L=\\PU
MA\RMCOBOLV12\WOWRT.DLL C=PRT.CFG" -workingdirectory "\\PUMA\CARPLAN\CARPLANLIV
+ CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOp
+ FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
but if I change the "-filepath" to "-command" I get...
Start-Process : A parameter cannot be found that matches parameter name 'comman
At C:\Program Files (x86)\Puma CarPlan\Puma CarPlan.ps1:1 char:23
+ start-process -command <<<< "\\PUMA\RMCOBOLV12\RUNCOBOL.EXE CAR001 K L=\\PUM
A\RMCOBOLV12\WOWRT.DLL C=PRT.CFG" -workingdirectory "\\PUMA\CARPLAN\CARPLANLIVE
+ CategoryInfo : InvalidArgument: (:) [Start-Process], ParameterB
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Comm