-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invocation of PS scripts from jPowerShell fails when the script path has space in it #58
Comments
Here is the sample code : PowerShellResponse response = powerShell.configuration(config).executeScript("C:/temp/OSCompat.ps1", "input1"); However in PowerShell class, the executeScript method internally calls this statement : //Create temp file method |
Hello, So if I have undertood well, in your case you are overriding the java.io.tmp.dir, using a path with spaces and that makes jPowershell fail when trying to create the temp file. So what you need is just an optional parameter in executeScript to override the temp directory:
Can you confirm it? Thanks for your feedback. |
Yes @profesorfalken . We want to customize the default temp directory location from java.io.tmp.dir to something else like ProgramData or %temp% path. So in such cases honouring the tempDirectory location in the existing framework would ease and suffice our requirement. Thanks. |
Hi again @senarha, You should be able to do it using the 3.1.0 version of jPowershell. You can configure the temp path programmatically:
Or just placing a configuration file called jpowershell.properties into your classpath with the content:
Can you try it? Best regards |
First of all thanks for putting the awesome library in place to suffice the requirement of invoking PS from Java. It provide almost all required api method which are very much required for any application to leverage and execute the PS script. Thanks once again.
We are using jPowerShell library to execute PS scripts from Java layer. We are using tomcat application which is installed in custom drive (non- OS installed eg: M:) with path to java.io.tmp.dir containing space in it (For eg: -Djava.io.tmp.dir="M:\Program Files (x86)\Tomcat)
Thus, When we invoke the executeScript method of jPowerShell script, while creating temp scripts using File.createTempFile("psscript_" + (new Date()).getTime(), ".ps1"); in PowerShell.java, invocation of PS scripts fails saying cannot locate script path with " (x86) ..."
Please note that as we are shipping jPowerShell along with our application to the customers who already have installed tomcat in it, we cannot recommend customer to enable the short path naming convention for the non-OS drive and changing the java.io.tmp.dir in java_opts might cause failure in application.
Please note that this is not an issue with application installed in OS drive with short name flag enable because they uses the short names instead of long path.
For eg: With Shortname enabled, the path would be similar to this
Djava.io.tmpdir=C:\PROGRA
2\TEST\TOMCATLIC1Recommendation:
If the jPowershell Library handles and accept the temp directory path while creating temp file, we can pass different path based on the input fed from user and create temp file in it. Please share your thoughts.
The text was updated successfully, but these errors were encountered: