I want to run a jar file from powershell. Till now I have been able to find this:
Start-Process -FilePath java -ArgumentList '-jar Upload_Download.jar FilePickupPath= $pickuppath FileDownloadPath= $download' -PassThru -RedirectStandardError E:\stderr.txt
Some how this is not working. Any suggestions?
Powershell has multiple string quotation characters that behave different ways. The double quote "
allows evaluations within the string whilst the single quote '
doesn't.
As a practical example:
$foo=42
write-host "The foo: $foo"
# Prints The foo: 42
write-host 'The foo: $foo'
# Prints The foo: $foo
The command uses single quote like so, (backtick is used to split the code into screen friendly format)
Start-Process -FilePath java `
-ArgumentList '-jar Upload_Download.jar FilePickupPath= $pickuppath fileDownloadPath= $download' `
-PassThru -RedirectStandardError E:\stderr.txt
This will pass literally $pickuppath
and $download
. The intention is likely to pass $pickuppath
and $download
's values.
In order to resolve the issue, use double quotes.