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 . . .
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 i.e '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
}