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 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染