Jump to content

Creating a new user using "Run" fails


Floutsch
 Share

Recommended Posts

Hi there,

I'm trying to create a user with Run which just won't work. I've been looking at it for hours and I don't get it... the code is as follows:

CODE
$call = "net user " & $localaccount_user & " " & $localaccount_pass & " /add /active:yes /fullname:Support@Home /passwordreq:yes";

MsgBox(0, "Test", $call)

Run(@ComSpec & " /c " & $call, "", @SW_HIDE)

if @error Then

MsgBox(17, "Error", "Support@Home user couldn't be created...")

Exit

EndIf

$localaccount_user and $localaccount_pass come from a GUI-window and therefor from the user. The MsgBox shows the correct call but it just won't create the user. Dropping the content of $call to the command line creates the user without any problems. I've tried RunWait, I've tried to Run only $call (without @ComSpec and so on) and even ShellExecute (didn't expect it to work, but hey...).

Uh, what else to tell you that might be important...? I've set 'AutoItSetOption("RunErrorsFatal", 0)'. And the first MsgBox in my example is obviously for debugging purposes, but it shows what I expect to work...

Link to comment
Share on other sites

No, I didn't. Would that be of any sense considering that the same user who calls the AutoIt script should also be the one executing the command? This very same user can take the command and get the new user created when trying it at the command line.

Besides: There's also #RequireAdmin in the script - forgot to write that ;)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...