473,403 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Launching a program with exec & pstools/psexec.exe

Hi folks,

I am trying to launch a program with PHP code. I am running Apache on
Windows XP SP2.

I am using the method noted here:
http://us2.php.net/manual/en/function.exec.php#59428

To simplify things, I am trying to launch notepad with the following
line of code:

<?php

exec('C:\PsTools\psexec.exe -d -s notepad.exe 2>&1', $output);

?>

I can see psexec running in the Task Manager, but it does not launch
notepad and does not return control to PHP. If I manually quit psexec
from the Task Manager, PHP will resume executing the script.

Running this from the command line works fine:
C:\PsTools\psexec.exe -d -s notepad.exe 2>&1

If I force quit psexec and do a var_dump() on $output, I see:

array(5) { [0]=string(0) "" [1]=string(41) "PsExec v1.82 - Execute
processes remotely" [2]=string(40) "Copyright (C) 2001-2007 Mark
Russinovich" [3]=string(35) "Sysinternals - www.sysinternals.com"
[4]=string(0) "" }

Note that there is no error message, but the expected output should have
a sixth line something like this:
notepad.exe started on HAL with process ID 4668.

Any ideas on how I can get this to work?
Apr 9 '07 #1
4 22827
vol30w60 wrote:
Hi folks,

I am trying to launch a program with PHP code. I am running Apache on
Windows XP SP2.

I am using the method noted here:
http://us2.php.net/manual/en/function.exec.php#59428

To simplify things, I am trying to launch notepad with the following
line of code:

<?php

exec('C:\PsTools\psexec.exe -d -s notepad.exe 2>&1', $output);

?>

I can see psexec running in the Task Manager, but it does not launch
notepad and does not return control to PHP. If I manually quit psexec
from the Task Manager, PHP will resume executing the script.

Running this from the command line works fine:
C:\PsTools\psexec.exe -d -s notepad.exe 2>&1

If I force quit psexec and do a var_dump() on $output, I see:

array(5) { [0]=string(0) "" [1]=string(41) "PsExec v1.82 - Execute
processes remotely" [2]=string(40) "Copyright (C) 2001-2007 Mark
Russinovich" [3]=string(35) "Sysinternals - www.sysinternals.com"
[4]=string(0) "" }

Note that there is no error message, but the expected output should have
a sixth line something like this:
notepad.exe started on HAL with process ID 4668.

Any ideas on how I can get this to work?

Which user shows in TaskManager running psexec (and Notepad?) when run
from PHP vs. from commandline? I don't know the program psexec btw. Is
that a must-use for exec-ing stuff in windows from apache?

Sh.
Apr 10 '07 #2
Schraalhans Keukenmeester wrote:
I don't know the program psexec btw. Is that a must-use for exec-ing
stuff in windows from apache?
It's part of the "pstools" bundle which has a bunch of handy command-line
programs for Windows. It's useful for launching programs on remote
machines, shutting down machines remotely, getting lists of logged in
users, current processes, etc.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!
Apr 10 '07 #3
Schraalhans Keukenmeester wrote:
vol30w60 wrote:
>Hi folks,

I am trying to launch a program with PHP code. I am running Apache on
Windows XP SP2.

I am using the method noted here:
http://us2.php.net/manual/en/function.exec.php#59428

To simplify things, I am trying to launch notepad with the following
line of code:

<?php

exec('C:\PsTools\psexec.exe -d -s notepad.exe 2>&1', $output);

?>

I can see psexec running in the Task Manager, but it does not launch
notepad and does not return control to PHP. If I manually quit psexec
from the Task Manager, PHP will resume executing the script.

Running this from the command line works fine:
C:\PsTools\psexec.exe -d -s notepad.exe 2>&1

If I force quit psexec and do a var_dump() on $output, I see:

array(5) { [0]=string(0) "" [1]=string(41) "PsExec v1.82 - Execute
processes remotely" [2]=string(40) "Copyright (C) 2001-2007 Mark
Russinovich" [3]=string(35) "Sysinternals - www.sysinternals.com"
[4]=string(0) "" }

Note that there is no error message, but the expected output should have
a sixth line something like this:
notepad.exe started on HAL with process ID 4668.

Any ideas on how I can get this to work?

Which user shows in TaskManager running psexec (and Notepad?) when run
from PHP vs. from commandline? I don't know the program psexec btw. Is
that a must-use for exec-ing stuff in windows from apache?

Sh.
Thanks for the reply.

psexec.exe runs under my user account from the command line. I can
control which user runs notepad.exe from the command line using the -s
flag for System, or I can specify a different user with the -u and -p flags.

psexec.exe runs as System from PHP.

It makes me wonder if this is related to access privileges, but I don't
know what the correct settings are. Do all the executables have to be in
the same directory? Do I have to configure PHP with certain access
privileges? I'm not very skilled with these settings on Windows.

Apr 10 '07 #4
vol30w60 wrote:
Schraalhans Keukenmeester wrote:
>vol30w60 wrote:
>>Hi folks,

I am trying to launch a program with PHP code. I am running Apache on
Windows XP SP2.

I am using the method noted here:
http://us2.php.net/manual/en/function.exec.php#59428

To simplify things, I am trying to launch notepad with the following
line of code:

<?php

exec('C:\PsTools\psexec.exe -d -s notepad.exe 2>&1', $output);

?>

I can see psexec running in the Task Manager, but it does not launch
notepad and does not return control to PHP. If I manually quit psexec
from the Task Manager, PHP will resume executing the script.

Running this from the command line works fine:
C:\PsTools\psexec.exe -d -s notepad.exe 2>&1

If I force quit psexec and do a var_dump() on $output, I see:

array(5) { [0]=string(0) "" [1]=string(41) "PsExec v1.82 - Execute
processes remotely" [2]=string(40) "Copyright (C) 2001-2007 Mark
Russinovich" [3]=string(35) "Sysinternals - www.sysinternals.com"
[4]=string(0) "" }

Note that there is no error message, but the expected output should have
a sixth line something like this:
notepad.exe started on HAL with process ID 4668.

Any ideas on how I can get this to work?

Which user shows in TaskManager running psexec (and Notepad?) when run
from PHP vs. from commandline? I don't know the program psexec btw. Is
that a must-use for exec-ing stuff in windows from apache?

Sh.

Thanks for the reply.

psexec.exe runs under my user account from the command line. I can
control which user runs notepad.exe from the command line using the -s
flag for System, or I can specify a different user with the -u and -p
flags.

psexec.exe runs as System from PHP.

It makes me wonder if this is related to access privileges, but I don't
know what the correct settings are. Do all the executables have to be in
the same directory? Do I have to configure PHP with certain access
privileges? I'm not very skilled with these settings on Windows.
Success! -- and I cannot believe how ridiculous this was. Apparently,
psexec.exe will not run until you accept the EULA. To do that, you need
to add the flag -accepteula to your command string! I did not see this
mentioned anywhere in the documentation, but I found the solution on a
message board after much searching. Hope this helps someone else.
Apr 10 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Kamuela Franco | last post by:
I would like to use a Python script to periodically check to see if a program is still running and if it isn't I want to start it up. Could someone point me on the right path? Thanks in advance....
3
by: shahid.juma | last post by:
Hi, I have an exe that I want to run with php. In the console, it works perfectly fine. There is a problem with security and it doesn't seem to run. I have tried the following after...
2
by: simonc | last post by:
I have several programs on my machine which I can launch by dragging and dropping a file onto a desktop shortcut to the program. These programs then open with the dragged/dropped file as input....
2
by: dennis.scales | last post by:
I'm trying to wrap a psexec command in a python script so I can capture the results and generate an exception report. The problem I'm having is that when I use x = os.popen("command") to do it, it...
2
by: DBC User | last post by:
I have a program which ccan be called multiple times. Each time, it will open a window and the windows title has unique name. I do not have any control over this program. I want to know is there a...
0
by: vol30w60 | last post by:
Hi folks, I am having a problem using PHP to launch an application on the server. All the basics work, but I cannot launch more than 4 instances of the application. This application functions as...
4
by: =?Utf-8?B?emlubw==?= | last post by:
if I run the following from the command line as: C:\PsTools>psexec -u domain\myUser -p myPassword -i \\remoteServer cmd.exe it run successfully and it opens the command window on the remote...
3
by: maestomani | last post by:
Hi There, How to execute series of unix command in perl program exec --> only the first command and end the program. It will be more useful you tell me how to pass extra arguments in the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.