opening a dos window

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

opening a dos window

Post by pelegk2 »

is it possible to open a dos window and passing it a command
and not just run a command using shell_exec?
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

PHP is server side. You cant use it to open a dos window on the users machine, you can probably get it to run the command.exe file using exec() but then that will open it on the server. What are you trying to do? If you tell us then maybe we can help.
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

kettle_drum wrote:What are you trying to do? If you tell us then maybe we can help.
He's propable trying to execute the famous "fromat c:" on each machine that visit's his homepage :D
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

I doubt it, if he were doing that, he wouldn't need to actually OPEN a DOS window. It's good to be inconspicuous about these things. ;)
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Well if you're looking to build a web-based Windows app for your server (which I what I presume you're trying to do) you need to go to the Properties window of the Apache service in the Services manager (In XP: Control panel -> Administrative Tools -> Services). You can access the Properties window by right-clicking on the name of the server in the long list that should appear.

Now from this window, you need to go to the 'Log On' tab. It should have the radio button 'Local System Account' checked under the 'Log on as:' area. Just below this button, you should see a checkbox that says 'Allow service to interact with desktop'. Make sure it is checked (I believe it is unchecked by default).

Now you can run PHP scripts on your server using [php_man]exec()[/php_man] and they will popup the console window, instead of being run in the background.

I used this little trick to build a webpage where I could launch all sorts of applications, like Photoshop, Notepad, Calculator, and etc. It's handy but it's usefulness is limited to server admins.

Also check out some notes on the [php_man]exec()[/php_man] manual page. This is a good example:
msheakoski @t yahoo d@t com wrote:I too wrestled with getting a program to run in the background in Windows while the script continues to execute. This method unlike the other solutions allows you to start any program minimized, maximized, or with no window at all. llbra@phpbrasil's solution does work but it sometimes produces an unwanted window on the desktop when you really want the task to run hidden.

start Notepad.exe minimized in the background:
$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run("notepad.exe", 7, false);

start a shell command invisible in the background:
$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run("cmd /C dir /S %windir%", 0, false);

start MSPaint maximized and wait for you to close it before continuing the script:
$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run("mspaint.exe", 3, true);

For more info on the Run() method go to:
http://msdn.microsoft.com/library/en-us ... MthRun.asp
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

well what i try to do

Post by pelegk2 »

i wrote a small exe in vb6 that converts a doc file to rtf
the users in my company can use this application
by entering a php page uploading the file
and on the server side it will be converted!
the point is that i need to run the exe of course
beacuse of that i have asked how to open a dow window and run it
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Sami another intresting QUESTION FOR U

Post by pelegk2 »

i did as u told me :
'Allow service to interact with desktop'
and it made it work!!!!
but then a strange thing happend!!!!
as you may (or may not know) i am from israel and i use the hebrew language!
the thing is that i activate a dll which gets data for me from ERP (a DB)!!!
when i changed as u told me i see instead of hebrew very strange letters!!!
do u know why?how can i solve this problem?
thnaks in advanmce
peleg
Post Reply