Muhammad Arslan Jamshaid
Muhammad Arslan Jamshaid

Reputation: 1197

Execute batch script with admin rights in windows 8.1 by exec()

I am trying to run a batch file from php with exec() but it is not working. When I run the same script in a command window in admin mode the script works.

Now I want to know how can I configure in php that my script can be execute with ADMIN mode.

Upvotes: 4

Views: 12383

Answers (1)

Harikrishnan
Harikrishnan

Reputation: 9979

You can use RunAs Command. Since it will ask admin password and you are running it from web you should pipe the admin password to the command.

exec('echo adminpassword | runas /user:administrator fullPathToProgram',$output);
print_r($output);

Upvotes: 6

Related Questions