473,668 Members | 2,519 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:\PsTool s\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\psex ec.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) "Sysinterna ls - www.sysinternal s.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 22867
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:\PsTool s\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\psex ec.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) "Sysinterna ls - www.sysinternal s.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:\PsToo ls\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\pse xec.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) "Sysinterna ls - www.sysinternal s.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:\PsTo ols\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\ps exec.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) "Sysinterna ls - www.sysinternal s.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
7144
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. Kamuela
3
2198
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 reading various newsgroups and websites and no luck.
2
965
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. Microsoft Notepad is an example. How do I set up one of my own programs to respond in this way? (In one example I want to do this with there is no user input at all - the program simply takes the input file, reformats it and writes the output...
2
3442
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 runs, but the content of x is empty. I know there should be output sent to it, because when I run the command from the DOS prompt, it shows it. I don't have this problem when wrapping other PSTools. Has anyone else had this problem, or can...
2
2959
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 way to find out which are all the windows open and also how to identify the windows title? I want to check if a particular window is opened with a known title. I know the title. I tried using Process and ProcessByName and it is not working...
0
1504
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 a server itself, and I specify the port number when I launch it, so my theory is that I am reaching some limit on network connections. This is my basic launch sequence:
4
15794
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 server if I try to run this same command from an asp net web page from the same server as : Dim p As New System.Diagnostics.Process Dim pi As New System.Diagnostics.ProcessStartInfo pi.FileName = "C:\PsTools\psexec.exe"
3
1552
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 command. BRs
0
8367
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8570
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8650
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7391
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5677
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4202
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2017
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1779
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.