Sorry if this has been asked and answered - the problem I'm having is
a big different from the standard "how do I run an exe from a
powershell script" that comes up all the time.
I'm trying to call an executable file that accepts several command-
line arguments from a Powershell script. The current line in the
script which starts our build process looks like this:
cmd /c "$makevb_program -path=$LOCAL_DIR\MAK\ -auto=N $MAKEVB_ARGS"
$makevb_program contains the full path to our compile utility.
What I would like to do is replace that with a & call, because I would
prefer to let powershell complete the script and exit rather than hang
while waiting for the build program to execute. I've tried this:
& "$makevb_program -path=$LOCAL_DIR\MAK\ -auto=N $MAKEVB_ARGS"
But I get the "is not recognized as a cmdlet, function, etc" error.
Is there a way to call an EXE file, with command line arguments, in
this way?
Thanks,
Sam
> & "$makevb_program -path=$LOCAL_DIR\MAK\ -auto=N $MAKEVB_ARGS"
Invoke-Expression should do it. I don't know why & won't though...
--
Hal Rottenberg
blog: http://halr9000.com
powershell category:
http://halr9000.com/article/category/programming/scripting/powershell/
& "$makevb_program" "-path=$LOCAL_DIR\MAK\" "-auto=N" "$MAKEVB_ARGS"
If you have PSCX (PowerShell Community Extensions) installed you can use
echoargs.exe. This
awesome utility can help you "see" how the target file/function processes
the arguments sent to it, thus
troubleshooting any argument related errors
Or visit here http://scriptolog.blogspot.com/2007/08/things-that-make-you-go.html
to get the PowerShell Version of echoargs.
Shay
http://scriptolog.blogspot.com
iex "$makevb_program -path=$LOCAL_DIR\MAK\ -auto=N $MAKEVB_ARGS"
# iex is Invoke-Expression's alias
--
Kiron
(Actually... it worked fine after I escaped all the hyphens. Oops.)
Also, thanks Shay for the reference to PSCX. I'm a PS newbie, although
I've done a fair amount of shell scripting in my Unix life, and I
expect that the extensions will be very helpful to me.
- Sam
Can't improve much on the above method, but another way is to add the
exe folder to your path:
$env:path += ";C:\Program Files\makevb_program"
Then you can just call it from the PS prompt without the hoohah:
makevb_program -path=$LOCAL_DIR\MAK\ -auto=N $MAKEVB_ARGS
-Hecks