简体   繁体   中英

call java from powershell with argument list

I have a script that runs a java app that needs to have a variety of augments.

If I drop this into PowerShell window it runs.

Start-Process -FilePath $JAVA\bin\java.exe -ArgumentList @( "-jar .\Assessor-CLI.jar","-b benchmarks\CIS_Oracle_Database_18c_Benchmark_v1.0.0-xccdf.xml", "-p ""Level 1 - RDBMS using Traditional Auditing""","-D ""myconnection string""", "-D ""xccdf_org.cisecurity_value_listener.ora=/u01/app/oracle/product/18.0.0/dbhome_1/network/admin/listener.ora""" ,"-csv -html", "-rp ""ol7db_Assessment_20200827_temp""", "-q")-NoNewWindow -Wait

The problem is that I need to run from inside a PS script that populates some of the variables. No matter how many quotes I put around those various arguments it seems to hang on the -p one like there aren't the right quotes.

here is what i call from inside of my PS script.

Start-Process -FilePath $JAVA\bin\java.exe  -ArgumentList @("-jar .\Assessor-CLI.jar","-b benchmarks\$benchmark","-p """"Level 1 - RDBMS using Traditional Auditing""""","-D """"$connect_info""""","-D """"$listener_info""""","-csv -html", "-rp ""$NEWREPORT_TEMP""","-q") -NoNewWindow -Wait

How can i understand to get this one to look like the first one?

It seems that I just needed to work better on the quotes. Once I put the quotes properly it worked just fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM