Page 1 of 1

opening a dos window

Posted: Tue Oct 26, 2004 1:42 am
by pelegk2
is it possible to open a dos window and passing it a command
and not just run a command using shell_exec?

Posted: Wed Oct 27, 2004 9:15 am
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.

Posted: Wed Oct 27, 2004 9:22 am
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

Posted: Wed Oct 27, 2004 10:29 am
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. ;)

Posted: Wed Oct 27, 2004 10:56 am
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

well what i try to do

Posted: Thu Oct 28, 2004 1:31 am
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

Sami another intresting QUESTION FOR U

Posted: Wed Nov 03, 2004 7:12 am
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