Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Dec 2009
    Posts
    173
    Thanks
    24
    Thanked 1 Time in 1 Post

    Just exec and don't output.

    How to use php exec() function to open in my OS not in the browser.

    I'm using this code :

    PHP Code:
    <?php
       exec
    ('"C:\Program Files (x86)\The KMPlayer\KMPlayer.exe" "C:\Wildlife.wmv"');
    ?>
    what i'm trying is to make kmplayer open this video. but seems like it wants to output it at the browser. how can i make it open kmplayer at my screen?
    Last edited by sorlaker; 01-12-2013 at 09:50 PM.

  • #2
    Regular Coder
    Join Date
    Dec 2009
    Posts
    173
    Thanks
    24
    Thanked 1 Time in 1 Post

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Does running that code on your command line open the executable? Also, I assume that you are attempting to run this on your local machine web server right? It's useless to even attempt that on a remote server which likely wouldn't have that KMPlayer installed (and has a higher probability of being a linux machine anyway).

  • #4
    Regular Coder
    Join Date
    Dec 2009
    Posts
    173
    Thanks
    24
    Thanked 1 Time in 1 Post
    Hm.. I want to control my laptop using my computer. Another thing is that my laptop is far and connected into a tv so i wanted to watch some videos there while i use the pc.

    Do you have any solution?

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Not using PHP as a web environment I don't. Running exec in a PHP script executes a command on the server, not on the client using it. That would be a tremendous security hole if it were possible to do.
    For that I'd suggest writing something in either Java or C#/VB.NET. Both should be fairly easy to set up, and on the same network you can set up the user as administrator on both machines.
    Also, as for the exec not working properly, this has to do with piping the output. Effectively trying to call a command is waiting for the command to return the output, and since some commands don't (such as trying to launch notepad), than it will just sit there running infinitely in the browser. Windows in particular is an absolute pain for exec.

  • Users who have thanked Fou-Lu for this post:

    sorlaker (01-12-2013)

  • #6
    Regular Coder
    Join Date
    Dec 2009
    Posts
    173
    Thanks
    24
    Thanked 1 Time in 1 Post
    I was actually thinking about that but i got an issue. I thought about accessing my laptop's cmd and open the file from there but i couldn't maximize it. How can i send data to kmplayer (like keyboard keys)? Can it be done from cmd or i have to use Java?

  • #7
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    You'd need to check your documentation. Typically if you are launching an application from command line, you'll need to provide it with all of the arguments it requires. PHP would be limited to trying to interact with the process itself (using proc family may be able to help with that). If there is a way for it to be done from the command line calls, than sure you can do that. Maximum and fullscreen options for video players can *likely* be performed at the command line call. If they have it in, you can try launching the executable with the /? on it which typically brings up the help menu in windows to show you what arguments it will accept.

    Java can make use of the Robot class which allows you to click on the screen. I've never tried to set up a client / server application which uses the robot before, but I'd presume you can issue commands remotely that would interact with the Robot. Positioning is where the pain will be.

    Is there any reason why you don't simply use remote desktop to control it instead? Sounds like it would be a lot easier than writing something to do it.

  • #8
    Regular Coder
    Join Date
    Dec 2009
    Posts
    173
    Thanks
    24
    Thanked 1 Time in 1 Post
    Actually i could send just an "Enter" key to KMPlayer to maximize it. I'm aware of those remote desktops but it takes a lot of time by typing computer's id and pwd (team viewer). So i'd like to use something fast that could not take a lot of the core's processor.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •