[英]How to run powershell command using groovy in soapui?
I wanted to run the below powershell command as a administrator in the groovy.. 我想以groovy中的管理员身份运行以下powershell命令。
PS C:\Program Files\APP\Bin> .\app.AdminTool.ps1 -url "https://reference1.jdm-inc.com" enqueue orchestration -file "C:\Program Files\APP\Importer\daily_report.xml" -properties @{ 'processing_date' = '2017-01-17' }
I have used following code to run this. 我已经使用以下代码来运行它。
String workingDir= System.setProperty("user.dir","C:\\Program Files\\APP\\Bin")
log.info(System.getProperty("user.dir"))
I kept the below command in the one variable. 我将以下命令保留在一个变量中。
.\app.AdminTool.ps1 -url "https://reference1.jdm-inc.com" enqueue orchestration -file "C:\Program Files\APP\Importer\daily_report.xml" -properties @{ 'processing_date' = '2017-01-17' }
I have tried the below command to change the path and 我试过下面的命令来更改路径和
def proc = "cmd /C dir".execute().text
return proc
This brings always soapui bin folder path.. How to change the path? 这总是带来soapui bin文件夹的路径。如何更改路径?
def powerShellCommand = '.\\app.AdminTool.ps1 -url "https://reference1.jdm-inc.com" enqueue orchestration -file "C:\\Program Files\\APP\\Importer\\daily_report.xml" -properties @{ \'processing_date\' = \'2017-01-17\' }'
def shellCommand = "powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -Command \"${powerShellCommand}\""
def process = shellCommand.execute()
process.waitFor()
Then you have access to the Process.outputStream to read the command output. 然后,您可以访问Process.outputStream以读取命令输出。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.