0

Im trying to run a .bat file on my server through php popen command, ive struggled and finally got to the point where all the permissions are set correctly and now i can actually execute the file but i have a problem. In my server logs it displays

foo.bat: line 1: mstsc: command not found, referer: http://dev.example.com

The full code in the file is mstsc /v:192.168.1.1 I know this means that it doesn't recognize the command on centos but im not sure what to do to fix the problem.

The aim of this code is to open RDP for the user who requested it. Bear in mind that this code works perfectly locally on my windows OS using xampp but when i upload it to the server running CENTOS it doesnt work.

My question is

How do i fix this error and allow CENTOS to execute a command that opens an RDP window for the user

2 Answers 2

2

Well, as pointed out by Federico Galli you are calling a Windows executable which is not present and cannot run on CentOS.

There are linux RDP clients, however: for example you could use rdesktop.

yum install rdesktop
rdesktop 192.168.1.1

I'm still dubious as to what you want to accomplish exactly, since you mention opening a RDP window on a server and servers are usually (but not necessarily) missing a graphical interface.

UPDATE: Based on your clarification, I understand that you want users with Windows clients to launch a RDP session when visiting via http a page on PHP website on a CentOS server. I would personally just provide a .rdp file to users to download and launch. Or you could see here and here.

5
  • I want to open the file locally, with my code locally on xampp it allows me to click a button on a web page and open RDP, but when i upload it to the server it doesnt work and throws that error but thats what im trying to accomplish
    – Keny iron
    Feb 28, 2017 at 10:49
  • I think I understand now. What you were trying is completely senseless, let me explain: the RDP connection must be made from a client (that has a graphical interface), but PHP on the server (which may not have a graphical interface) cannot, normally, issue commands (such as launch an application) on the clients. The only reason it works with your WAMP setup is that the client and the server are in that case the same machine.
    – simlev
    Feb 28, 2017 at 10:58
  • I get you but the only reason im trying to simulate this is because its been done before by other companies, the only problem is i dont know how and ive looked around the internet and this is the closest answer that ive come up with, not going to lie theres not much help available with this subject and its proving to become a really difficult task to accomplish, i just know its doable so i want to do it.
    – Keny iron
    Feb 28, 2017 at 11:03
  • Thanks for the extra information ill look more into these links and get back to you
    – Keny iron
    Feb 28, 2017 at 11:05
  • Thanks for this i seriously had to take a step back and slow down for me to actually get somewhere, seen as i had no idea where to start with this i was looking in all the wrong places and have added a heap of code it that works in development but not production, exactly what i was looking for thanks for the help and patience
    – Keny iron
    Feb 28, 2017 at 11:20
1

That command does not exist on linux servers. It's a Microsoft software.

Mstsc. Creates connections to Remote Desktop Session Host (RD Session Host) servers or other remote computers, edits an existing Remote Desktop Connection (.rdp) configuration file, and migrates legacy connection files that were created with Client Connection Manager to new .rdp connection files.

3
  • Right so i knew this partially, how do i solve my problem
    – Keny iron
    Feb 28, 2017 at 10:45
  • If i understand correctly you are trying to create local web page to open a remote connection from a remote server. This is not actually logic. What are you trying to accomplish? As pointed from simlev you could use rdesktop util but still wont work as you designed it. Feb 28, 2017 at 11:05
  • Then you dont understand correctly, im trying to launch rdp through the website either by url or button or function as i said what mislead me is that it works perfectly fine on xampp on my windows OS. simlev has provided me with some more information and links so ill look into those thanks
    – Keny iron
    Feb 28, 2017 at 11:07

You must log in to answer this question.

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