-1

I have a web app which runs on a local server (XAMPP)...its on a computer (PC1) which serve as a server..other computers are connected to the same wireless network and can run the web app also from the network.

Problem now is, i have a code that executes a bat file which is stored on the server (PC1), but if PC2 runs the code...the effects will be on PC1, i want a way that if PC2 or PC3 runs the script that executes the bat file...it will execute it on PC2 or P# which runs the script.

2
  • You haven't told us how your PHP script is launching the batch file, or what the batch file is doing. What exactly are you expecting us to answer here? We can't read your mind and figure out what you are trying to do. Without that we can't make any useful suggestions. Also, I strongly suspect you are doing something I would personally consider to an extremely bad idea. Granting a web server the ability to remotely execute software on the computers on your network seems to me like a recipe for disaster.
    – Zoredache
    Apr 14, 2015 at 18:56
  • @Zoredache im using php exec function like this exec('start c:/start.bat.lnk') thiat is a shortcut to a bat file that stops a windows service "printer spooler" i want to use the script to restart windows printer spooler on any PC that its ran on...but currently it will only run on the server PC even when the script was executed from another PC Apr 14, 2015 at 19:31

1 Answer 1

0

Don't use PHP for this. You should set up a Windows share so all computers connected to the network have access to the batch file. Then you can use a relative path all computers can access like /mappedrive/

I suggest you look into Powershell as well, which may be easier for this specific task.

At least that is how I would do that. Using exec is a security risk. Some PC's on the network could be infected and it would be possible to exploit your web server to retrieve banking information. Not a good idea to use exec, like ever even on internal networks.

Also look into the Windows task scheduler which you can use to trigger execution of batch files.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .