0

PHP file

<?php
echo exec("rules.bat");
?> 

BAT file

net user username Welcome12! /ADD /FULLNAME:Test /PASSWORDCHG:NO

When I try to run the php script I get the following

C:\inetpub\wwwroot\e\sso\home>net user username Welcome12! /ADD /FULLNAME:Test /PASSWORDCHG:NO

But no user is added. I can run the BAT file from the same directory and the user is added. I've also tried to run the following in my php script and it doesn't work

<?php
echo exec("net user username Welcome12! /ADD /FULLNAME:Test /PASSWORDCHG:NO");
?> 

I've also tried using system, shell_exec, passthru

When I run

echo exec("whoami");

it shows my user that has admin rights

mike peterson
  • 31
  • 1
  • 1
  • 4
  • possible duplicate of [link](http://stackoverflow.com/questions/835941/how-do-you-run-a-bat-file-from-php) or [link](http://stackoverflow.com/questions/27924184/execute-bat-file-from-php-in-background) ? At least one other command that might work is discussed there – lessthanideal Jun 26 '15 at 17:08

2 Answers2

0

What windows version? Does it have Admin Rights? as to add a user to windows you will have to run in Admin mode / Root Rights.

Even running net user username Welcome12! /ADD /FULLNAME:Test /PASSWORDCHG:NO in Command, returns: Access is denied.

Web server has 1User with rights, When logged into the Device i.e. RDP you possibly have Admin rights.

Stating the obvious here, But this is what it sounds to me

Dave Hamilton
  • 675
  • 1
  • 12
  • 23
  • I've created a user with admin rights as well as created a new application folder giving that user the rights in IIS 7.5 on windows 2008 R2 – mike peterson Jun 26 '15 at 16:59
0

echo exec(" start cmd /c net user $directoryname $password /ADD /FULLNAME:$username /PASSWORDCHG:NO");

this resolved it

mike peterson
  • 31
  • 1
  • 1
  • 4