1

I must kill remotely a process (for example calc.exe) but when I try to load my PHP page on internet it keeps loading and does nothing here is multiple techniques I have used but none of them work:

exec("pskill \\\\ipadress calc -u user -p pass")

exec("pskill \\ipadress calc -u user -p pass")

exec("pskill \\\\ipadress calc -u user -p pass >NUL")

exec("C:\Windows\system32\cmd.exe /k kill_myprogram.bat");
--> "pskill \\ip calc.exe -u user-p pass"

and:

WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run("cmd /C C:\path\toto.vbs", 0, false);
---> Set OShell=CreateObject("Wscript.Shell")
strCommand="pskill \\adress -u user -p pass program"
OShell.Run strCommand 
$oExec = $WshShell->Run("cmd /C C:\path\kill_myprogram.bat", 0, false)
halfer
  • 19,824
  • 17
  • 99
  • 186
Levrifon
  • 13
  • 6
  • For paths in PHP, I'd use the forward slash - it will convert it. The backslash may be being escaped in your `exec` with the full path in it. I wonder whether this doesn't work because your web server does not have the right permissions to kill off tasks as you do from the console. – halfer Apr 09 '14 at 09:14
  • Thank you for your answer I will try it .. but if it doesn't work I don't know what to do because with a cmd it is fine it kills the process remotely but with the php I can't do it ( sorry for bad english ) – Levrifon Apr 09 '14 at 09:16
  • I believe you can give your web server process more permissions, I think you do this in IIS (but it's been too many years since I've done this). I suspect it would have been answered here before though, have a search? – halfer Apr 09 '14 at 09:18
  • I will look into this direction if it works i will post here how :) – Levrifon Apr 09 '14 at 09:20
  • (I assume you're using IIS and not Apache? Of course, you'll need to set permissions for the server you're using). – halfer Apr 09 '14 at 09:22
  • hmm i think it is Apache ( Apache HTTP Server ) – Levrifon Apr 09 '14 at 09:24
  • When i am in Process Explorer I see : cmd.exe pskill.exe but it does nothing .. but it is running – Levrifon Apr 09 '14 at 09:58
  • I found how to do ! pskill.exe was freezing the page because it was waiting an argument : exec('cmd.exe /C START yourpath/your_kill.bat') In the .bat : call pskill \yourname -u user -p pass program -accepteula >> eventual_log_file.txt But now I have an other problem .. i would like to pass a parameter from PHP to the .bat for example : exec('cmd.exe /C START mypath/mykill.bat parameter1') in the .bat : call pskill \myparameter ... – Levrifon Apr 09 '14 at 12:29
  • See [this answer](http://stackoverflow.com/a/22961816/472495) from today - you need to escape strings injected into exec commands. – halfer Apr 09 '14 at 12:39

0 Answers0