Page 1 of 1

Problems with exec and psexec

Posted: Wed Jan 19, 2011 11:38 am
by juantxito
Hi,

I'm having a big problem using the exec() function. I want to execute a remote cacls to view and parse the returned accesslist. I use PsExec from SysInternals, and it's a Windows environment (and active directory) with apache. The problem is this:

Making some tests, I have checked thar the following line works:

$comando = 'psexec \\\\'.$_CONFIG['equipoRemotoPsExec'].' -u '.$_CONFIG['userPsExec'].' -p '.$_CONFIG['passwdPsExec'].' -accepteula cacls "C:\\Install\\SUPPORT"';

exec ($comando, $arr );

and it returns the accesslist.

(psexec \\remote address -u user -p password -accepteula command)

But the remote folder must be a parameter (variable) and after spending too many hours, I`ve checked that if the destination folder parameter has some spaces, it won't work (and it could happen):

$comando = 'psexec \\\\'.$_CONFIG['equipoRemotoPsExec'].' -u '.$_CONFIG['userPsExec'].' -p '.$_CONFIG['passwdPsExec'].' -accepteula cacls "C:\\Documents and Settings\\All Users\\Desktop"';

exec ($comando, $arr);

Any suggestions or ideas? Has someone have this problem too?

Thak you very much and sorry about my english,

Juan

Re: Problems with exec and psexec

Posted: Thu Jan 20, 2011 1:43 am
by Peter Kelly
When its a space change it to %20 possibly?

Re: Problems with exec and psexec

Posted: Thu Jan 20, 2011 2:28 am
by juantxito
Uhmm... good idea, thank you, but it doesn´t work. I'm afraid I'll must rename all the files and directories in the remote computer that could be searched by removing all the blank spaces in their names...

Thank you very much for the reply !!