note 83850 deleted from function.exec by cmb

From: Date: Sun, 24 Nov 2019 08:55:15 +0000
Subject: note 83850 deleted from function.exec by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-213218@lists.php.net to get a copy of this message
Note Submitter: engtejeda at hotmail dot com ---- Task: Invoke psexec from php to execute a command on a remote computer. Environment: -Windows XP Professional, Service Pack 3 -Apache 2.2 Installed (I used the version bundled in XAMP 1.6.6a) -The executable to be run must be in your system PATH!! PHP Script: <?php exec ("psexec -u someusername -p somepassword -c \\\\someipaddressORHostname someprogram.exe"); #sample command #exec ("psexec -u JoeShmoe -p ShrimpLover529 -c \\\\192.168.22.156 cleanfiles.exe"); ?> Problems: -I kept getting Access Denied Errors Observation(s): -I noticed that when I put that same psexec command in a batch file and started that batch file with the system account, I would get the same error -This lead me to the cause Cause: -Apache was running as the system account, and so any process invoked by php was started as the system account -Starting a batch file that accesses a remote computer using the local system account is a NO NO (at least for my setup) Solution: -Configure the Apache service to start as an account other than system (It must have appropriate permissions on the local computer) Start-->Run-->Services.msc-->RightClick Apache Service-->Properties-->Logon Tab-->Enter in value for "Log on As" Now load the same php page again. Look at the error.log again You should see an error code 0 returned for the process executed, indicating a successful run

« previous php.notes (#213218) next »