duan1930 2012-09-18 18:17
浏览 139

使用PHP Exec()命令运行WINRS / WINRM cmd

Platform Details: IIS7, PHP5, Windows Server 2008 Server Name: server1

I'm attempting to use php's exec() function to execute a .bat file which has the following command:

winrs -r:server2 "C:\custom_functions.bat"

However, when I execute that command, it does not work. When running the custom_functions.bat file directly on server2, it works fine therefore, the problem is not likely to be my code. I'm guessing its a permissions error.

When I execute exec("whoami"), it returns "nt authority etwork service" as the user.

If I execute any basic windows commands through php exec() function such as exec("ipconfig") or exec("dir c:\"), they work fine. The problem comes when I'm trying to use WINRM to execute a command on a remote server. I have used php's system() function as well - with same results.

Please help!?

  • 写回答

1条回答 默认 最新

  • dqphg40600 2012-09-18 18:25
    关注

    To run a command on a server, you need authorization on that server. When you run the command manually from the prompt, you have access through your user account.

    When IIS runs the command, it runs as a build in user, that has no access to server2.

    I do not advise to give the webserver process access to server2.

    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料