0

I have a curious issue with MSG.EXE, the (relatively) new method by Windows to issue network popup messages.

The following statement: msg aag /SERVER:100.100.100.22 /TIME:15 /V TEST works fine from a Win7 cmd window, and the server receives the message immediately.

In PHP, however, shell_exec ("msg aag /SERVER:100.100.100.23 /TIME:15 /V ".$emailHeader); does not produce any message and does not return any results either.

As a temporary workaround, I have embedded the first statement into a *.CMD batch file, which I call from PHP. However, (1) that is anything but elegant, and (2) it leads to up to 60 seconds delay in the transmission of the MSG, which in my case is a deal-breaker.

Any ideas on how to call MSG.EXE properly from PHP?

aag
  • 680
  • 2
  • 12
  • 33
  • 2
    Are you executing the php under a webserver? That's a completely different permissions environment and the fact that a manual command line test works means nothing. – Marc B Jul 22 '12 at 15:10
  • In case msg.exe requires a windows login session, it may fail on a web-server. Calling MSG.EXE using COM might probably help. The a *.CMD batch file forces a delay of 60 seconds is very, very unlikely. – SteAp Jul 22 '12 at 15:22
  • Marc B, thanks for your response. And yet, invoking the CMD batch file with exec() works. The /system32 folder, where MSG.EXE resides, is contained in the include_path. What else needs to be done to assign the right permissions? – aag Jul 22 '12 at 15:24
  • SteAp, can you explain what you mean by "using COM"? Thanks – aag Jul 22 '12 at 15:25
  • ftom2, I thought shell_exec() is for returning the entire output of the external command, irrespectively of the operating system. – aag Jul 22 '12 at 15:26

0 Answers0