fishmong3r
fishmong3r

Reputation: 1434

Cmd script in shell_exec fails to run

I need to add users to a local windows group via PHP. This is my attempt:

<?php
$output shell_exec('net localgroup groupname /add domain\user');
echo $output;
?>

I get Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\test\acc.php on line 2. I suppose it's some escaping issue but I can't figure it out. Tried double backslash \\ but didn't help.

Upvotes: 2

Views: 460

Answers (1)

Harshit
Harshit

Reputation: 5157

You forgot to assign the returned value to $output variable

$output = shell_exec('net localgroup groupname /add domain\user');

Upvotes: 2

Related Questions