0

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\network 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!?

mraliks
  • 3,897
  • 3
  • 13
  • 9

1 Answers1

0

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.

JvdBerg
  • 21,117
  • 8
  • 31
  • 54