I am trying to run 2 cmd command in PowerShell but an error displayed.
CMD
cd C:\apache-jmeter-5.2.1\bin
.\jmeter -n -t C:\User-search.jmx -l C:\Result.jtl
Error
PS C:\apache-jmeter-5.2.1\bin> .\jmeter -n -t C:\User-search.jmx -l C:\Result.jtl
.\jmeter : 'findstr' is not recognized as an internal or external command,
At line:1 char:1
+ .\jmeter -n -t C:\User-search.jmx -l C:\Result.jtl
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: ('findstr' is no...ternal command,:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
operable program or batch file.
Not able to find Java executable or version. Please check your Java installation.
errorlevel=2
When I open new PowerShell instance with runas administrator then the command runs successfully.
I tried the below command and it opens the new PowerShell window as administrator but error is same
Start-Process powershell -Verb runAs ".\jmeter -n -t C:\User-search.jmx -l C:\Result.jtl"
Error
'findstr' is not recognized as an internal or external command,
operable program or batch file.
Not able to find Java executable or version. Please check your Java installation.
errorlevel=2
Press any key to continue . . .
You can use the Cmdlet Invoke-Command
to execute a command with a specific credential:
Invoke-Command -ScriptBlock {
Set-Location C:\apache-jmeter-5.2.1\bin
& C:\apache-jmeter-5.2.1\bin\jmeter -n -t C:\User-search.jmx -l C:\Result.jtl
} -Credential Administrator
Please test it and let me know!
Finally, I am able to run it...
Actually, before running Jmeter I added below 3 paths to the Path environment variable.
C:\Windows\System32
C:\Program Files\Java\jdk-13.0.2\bin
C:\apache-jmeter-5.2.1\bin
Now I removed the 3rd path ie 'C:\\apache-jmeter-5.2.1\\bin' and run the command inside ScriptBlock
Invoke-Command -ScriptBlock {
cd C:\apache-jmeter-5.2.1\bin
.\jmeter -n -t C:\User-search.jmx -l C:\Result.jtl
}
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.