开发者

Running shell_exec as a different user on Windows

开发者 https://www.devze.com 2023-01-31 12:14 出处:网络
I feel like I\'m close t开发者_JAVA百科o the answer, but I\'m not quite there. I have a command line program that I call from a PHP. I use shell_exec(), and it runs on a Windows machine running an Apa

I feel like I'm close t开发者_JAVA百科o the answer, but I'm not quite there. I have a command line program that I call from a PHP. I use shell_exec(), and it runs on a Windows machine running an Apache server.

When I run the script, I see in Task Manager on the Windows machine that the process has started, and then promptly stops doing anything. The process is still running, but it takes up about 17 MB of space and then the PHP script just sits there loading.

The program is tiny (3MB) and it can handle files well over that size, and it's currently only handling one file that's 28 KB. When I call either one from a command prompt as the 'administrator', they work fine. When I call this one from shell_exec, it doesn't. I've also tried exec() and passthru().

I have noticed that when PHP calls the program, it shows up under the SYSTEM user. I've checked permissions on the Security tab of both the program and the file being processed by the program, and SYSTEM, Users, and Administrators all have full control over them.

What am I doing wrong?

If I need to run it as 'administrator' instead of SYSTEM, how do I do that?

I can elaborate more if you have questions.

Thank you so much, this has been killing me!


Please check whether safe mode is off in PHP configuration. If safe mode is on, you can only execute executables within the safe_mode_exec_dir. To make safe_mode off, open php.ini file in a text editor and search for “safe_mode”. Make sure that it is turned off (i.e. safe_mode = Off)

Also please try other Program execution functions such as system(). Refere here Apache server has run as user/group setting in the httpd.conf file


I had similar problem.

My solution is:
Just start Apache2 service with administrator's credentials

0

精彩评论

暂无评论...
验证码 换一张
取 消