开发者

PHP exec() function

I developed a program on windows xp and I used exec to run a ".bat" file and it worked fine. I copied the exact program on windows 2003 and the bat file didn't run. I used echo before the exec function and it seemed to work fine, I mean it echoed :

D:\xampp\htdocs\x>RunDLL32开发者_Go百科.EXE printui.dll,PrintUIEntry /y /n "HP LaserJet P2015 Series PS"

but it didn't do anything. I ran the bat file alone and it worked fine. Just doesn't work with exec in windows 2003. any ideas?


Is safe mode enabled on that server? If so then you won't be able to execute programs like that. You either need to turn safe mode off or add that directory to the safe_mode_exec_dir in PHP.ini

From the manual

Note: When safe mode is enabled, you can only execute files within the safe_mode_exec_dir. For practical reasons, it is currently not allowed to have .. components in the path to the executable.


If you are using IIS, in order to execute an application the Internet Guest account needs execute rights on CMD.exe. As every shell execute is run as CMD.exe -c <your command>.

Then verify that a simple echo system("dir"); works. This should return the directory listing of the current folder.

It is also likely you will have to give the Internet Guest account execute rights to the batch file, and any executable it executes (in this case rundll32.exe).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜