I am using PowerShell script to start a Java application.
$app = Start-Process -FilePath java -ArgumentList "-jar $path_to_jar" -PassThru
OR
java -jar $path_to_jar
When I am running this script, in PowerShell Core it's executing properly , but if I run the same script in normal PowerShell (Windows PowerShell) - it's giving error "Unable to access jarfile"
Even if I run PowerShell (Windows PowerShell) with Admin privilege getting same result, whereas PowerShell Core working without Admin Privileges
Any help is appreciated.
$path_to_jarcontain a relative or absolute path? Windows PowerShell does not update the process working directory when you change location withcd/{Set,Push,Pop}-Location, so relative paths passed to executables (likejava.exe) might resolve differently[environment]::CurrentDirectory = $PWDright before invoking java in Windows PowerShell