By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,751 Members | 1,216 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,751 IT Pros & Developers. It's quick & easy.

How can I execute a command from php on Windows

P: 5
Just I want to execute a command through PHP program.
Thanx & Regards
Mahmood Ali
Feb 8 '08 #1
Share this Question
Share on Google+
8 Replies


harshmaul
Expert 100+
P: 490
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?
Feb 8 '08 #2

Markus
Expert 5K+
P: 6,050
have a look at exec()

:)
Feb 8 '08 #3

harshmaul
Expert 100+
P: 490
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...

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. header("Content-type: application/bat");
  3. header("Content-Disposition: attachment; filename=notepad.bat");
  4. notepad.exe
  5. ?>
The above will load up notepad on the client.
Feb 8 '08 #4

P: 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>
Feb 9 '08 #5

P: 5
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>
-------------------------------------------------
Feb 9 '08 #6

harshmaul
Expert 100+
P: 490
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?
Feb 9 '08 #7

P: 5
Yes

Thank you so much.
Feb 12 '08 #8

harshmaul
Expert 100+
P: 490
Hi, in a new html page write the following code....

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. header("Content-type: application/bat");
  3. header("Content-Disposition: attachment; filename=notepad.bat");
  4. mstsc.exe
  5. ?>
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 **

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. header("Content-type: application/rdp");
  3. header("Content-Disposition: attachment; filename=rdp.rdp");
  4. ?>
  5. screen mode id:i:2
  6. desktopwidth:i:**SCREEN WIDTH
  7. desktopheight:i:**SCREEN HEIGHT
  8. session bpp:i:16
  9. winposstr:s:0,1,4,4,1056,562
  10. auto connect:i:0
  11. full address:s:**HOST
  12. compression:i:1
  13. keyboardhook:i:2
  14. audiomode:i:0
  15. redirectdrives:i:0
  16. redirectprinters:i:1
  17. redirectcomports:i:0
  18. redirectsmartcards:i:1
  19. displayconnectionbar:i:1
  20. username:s:**LOGIN
  21. domain:s:
  22. alternate shell:s:
  23. shell working directory:s:
  24. disable wallpaper:i:0
  25. disable full window drag:i:0
  26. disable menu anims:i:0
  27. disable themes:i:0
  28. bitmapcachepersistenable:i:1
  29.  
Feb 12 '08 #9

Post your reply

Sign in to post your reply or Sign up for a free account.