is it possible to open a dos window and passing it a command
and not just run a command using shell_exec?
opening a dos window
Moderator: General Moderators
-
kettle_drum
- DevNet Resident
- Posts: 1150
- Joined: Sun Jul 20, 2003 9:25 pm
- Location: West Yorkshire, England
-
Shendemiar
- Forum Contributor
- Posts: 404
- Joined: Thu Jan 08, 2004 8:28 am
- evilmonkey
- Forum Regular
- Posts: 823
- Joined: Sun Oct 06, 2002 1:24 pm
- Location: Toronto, Canada
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:
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
- 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
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
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
- 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
i did as u told me :
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
and it made it work!!!!'Allow service to interact with desktop'
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