-
Notifications
You must be signed in to change notification settings - Fork 29
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
Powershell not available on localHost #53
Comments
Hi, What is the return when you execute (as PHP user) on cmd? Just use exec(), that will mimic the execution done by the lib: |
On cmd i get:
And on browser: []
1 |
Hi, Return code 1 means the command encountered an error. exec() is not super verbose when it comes to returning error messages. Chances are your php user is locked to a subset of commands, or unable to traverse up the filesystem. Both pretty good practices for any public facing service. Try to determine if this is a general exec() permissions issue or a power shell specific issue what does each of the following commands return if triggered through php exec()? if no return please provide return straight from cmd.
|
|
Hi, Thats just downright strange. Appears where is not in the environment path for the server. Return of these last two commands please:
|
Hi.
|
Hi, Turns out i have let us on a bit of a wild goose chase, mostly because exec() is so vague in its return. The help for "where" states:
Since you received a return code 1 when running "where powershell" in your first reply to this issue, it appears "where" is available in your environment, but it was unsuccessful in locating "powershell.exe". Now this issue gets really wonky, because you just confirmed "where" is able to locate "powershell.exe", but only when you use the absolute path for "where". I have zero idea why that is. Are you 100% sure you are executing using the same user/environment when running MTS and when triggering the exec() commands above? Is it possible MTS is running on a server and the exec() commands are executed on your local dev box? Its a silly question, but none of this makes sense because by default "where" will search the current directory and the environment path. There is no indication that behavior changes depending on if "where" is triggered with or without an absolute path. Back to the issue at hand, your PHP user needs the powershell directory path in the PATH variable for the environment. You can check if it is by running:
Somewhere in the $data return you should see:
If it is not there you can either append it to the system path (best option) or do it at runtime before executing MTS:
There is a chance your path variable is larger than 1024 chars, in that case read this. Good luck. |
in some case we need to restart our windows to get some Environment @merlinthemagic answer will gonna help a lot to debug the |
Throw Exception
How to fix that?
The text was updated successfully, but these errors were encountered: