duanjing9339 2012-10-05 11:16
浏览 116
已采纳

PHP - 无法使用exec命令打开.exe文件

I work with PHP 5.4, IIS 7.5.

If execute a simple command, it works:

<?php
    exec("dir", $r);
    print_r($r);
?>

But if open .exe file, it doesn't work, the page is loading until the php timeout and doesn't open the notepad:

<?php
    exec("notepad.exe", $r);
    print_r($r);
?>

And if execute the notepad's php in command line, it works:

php -f <file>

I think that the problem is with IIS, but I don't know what. Thanks!

UPDATE

I did another test case and doesn't work, the page finishes loading but doesn't delete the task:

<?php
    $r = exec("SCHTASKS.exe /Delete /TN TaskTest /F");
    print_r($r);
?>

The IIS_IUSRS have permission for execute the schtasks.

SOLUTION

Notepad doesn't open because is a interactive program.

For Tasks scheduler, gives read and write permissions to the task folder (C:\Windows\System32\Tasks) to IUSR.

  • 写回答

2条回答 默认 最新

  • duanquanzhi5560 2012-10-05 11:21
    关注

    What makes you think it isn't working?

    Be aware that windows services cannot normally interact with the desktop, so it may be the case that notepad is starting, just not anywhere you can see it - and as PHP will wait for it to terminate, and nobody can see it to terminate it, it'll timeout, as you're seeing.

    It may also be the case that the user that the web server is running as does not have execute permissions on the folder that notepad is in (assuming it had the relevant path).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器