How can I execute a command from php on Windows

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mahmoodtyagi
    New Member
    • Feb 2008
    • 5

    How can I execute a command from php on Windows

    Just I want to execute a command through PHP program.
    Thanx & Regards
    Mahmood Ali
  • harshmaul
    Recognized Expert Contributor
    • Jul 2007
    • 490

    #2
    Hii,

    what do you mean you want to execute a command.
    Do you eant to execute the command on the client or the server?
    what kind of command?

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #3
      have a look at exec()

      :)

      Comment

      • harshmaul
        Recognized Expert Contributor
        • Jul 2007
        • 490

        #4
        True,
        but exec() is for server side, if you want client side you will need to look at "content dispositioning" the file in to a batch file....

        eg...

        Code:
        <?php
        header("Content-type: application/bat");
        header("Content-Disposition: attachment; filename=notepad.bat");
        notepad.exe
        ?>
        The above will load up notepad on the client.

        Comment

        • mahmoodtyagi
          New Member
          • Feb 2008
          • 5

          #5
          Thanx, but exec() is not working.......
          just I want to run "mstsc.exe" command when I click on anchor Tag: <a href="test.php" >Click to Run</a>

          Comment

          • mahmoodtyagi
            New Member
            • Feb 2008
            • 5

            #6
            Thanx,
            on server side
            just I want to run "mstsc.exe" command when I click on anchor Tag: <a href="test.php" >Click to Run</a>
            -------------------------------------------------

            Comment

            • harshmaul
              Recognized Expert Contributor
              • Jul 2007
              • 490

              #7
              Hi,

              So letme gety this write. You want a web site, that when a user clicks a link, they get a prompt to log in to a remote PC/Server?

              Comment

              • mahmoodtyagi
                New Member
                • Feb 2008
                • 5

                #8
                Yes

                Thank you so much.

                Comment

                • harshmaul
                  Recognized Expert Contributor
                  • Jul 2007
                  • 490

                  #9
                  Hi, in a new html page write the following code....

                  Code:
                  <?php
                  header("Content-type: application/bat");
                  header("Content-Disposition: attachment; filename=notepad.bat");
                  mstsc.exe
                  ?>
                  When you run it the browser will ask if you would like to download it, and then if you click run it will launch copmmand prompt, and load up the remote desktop...

                  Alternatively if the page is going to be secure you could do it like this.....
                  but don't forget to change the variables to those appropriate to you... (i started all you should change with **

                  Code:
                  <?php
                  header("Content-type: application/rdp");
                  header("Content-Disposition: attachment; filename=rdp.rdp");
                  ?>
                  screen mode id:i:2
                  desktopwidth:i:**SCREEN WIDTH
                  desktopheight:i:**SCREEN HEIGHT
                  session bpp:i:16
                  winposstr:s:0,1,4,4,1056,562
                  auto connect:i:0
                  full address:s:**HOST
                  compression:i:1
                  keyboardhook:i:2
                  audiomode:i:0
                  redirectdrives:i:0
                  redirectprinters:i:1
                  redirectcomports:i:0
                  redirectsmartcards:i:1
                  displayconnectionbar:i:1
                  username:s:**LOGIN
                  domain:s:
                  alternate shell:s:
                  shell working directory:s:
                  disable wallpaper:i:0
                  disable full window drag:i:0
                  disable menu anims:i:0
                  disable themes:i:0
                  bitmapcachepersistenable:i:1

                  Comment

                  Working...