Sign in to follow this  
Followers 0
au3scr

User Accounts

12 posts in this topic

How i make script that add's new user?

In cmd:

net user NewAccountName /add

net user NewAccountName *

<new password>

<ReEnter password>

But how to do same thing with autoit?


Share this post


Link to post
Share on other sites



Look in the helpfile. There is a very clear command.

Share this post


Link to post
Share on other sites

I couldnt find it, sorry

Can you say me what word in help file should i search?


Share this post


Link to post
Share on other sites

Look in the helpfile. There is a very clear command.

Well, I looked for it, and I couldn't find it either. I used in my search "account", and "user" with no hits. I also scrolled through all the commands and did not se what you are referring to.

@au3scr: you could use _runDOS to do it.

Share this post


Link to post
Share on other sites

Something like this?

Adduser("normaluser");normal user
Adduser("adminuser", 1);Admin user
Func Adduser($username, $admin = 0)
    RunWait(@ComSpec & " /c " & 'Net user ' & $username & " /add", "", @SW_HIDE)
    If $admin = 1 Then RunWait(@ComSpec & " /c " & 'Net Localgroup Administrators ' & $username & " /add", "", @SW_HIDE)
EndFunc   ;==>Adduser

Share this post


Link to post
Share on other sites

How about create a batch file with your code in it.

(Just open a new notepad and save as "newUser.bat")

From AutoIt, Use RunWait("newUser.bat")

Share this post


Link to post
Share on other sites

I already gave him this and it works as expected.

ok... so that means no more help is allowed?

that's a very effective strategy, except for the diminishing intellectual expansion that will be seen as a result.

Share this post


Link to post
Share on other sites

How about create a batch file with your code in it.

(Just open a new notepad and save as "newUser.bat")

From AutoIt, Use RunWait("newUser.bat")

That was your help...

I am just pointing out what is more efficient, has already been posted.

I am definitely not saying no more help is wanted. But lets move in the right direction.

No need to take this personally, like it appears you were. This isn't an attack on you, or anything you posted. Settle down.

I am merely pointing out the fact that calling an external batch file isn't an autoit solution.... this IS the autoit forum though.

Share this post


Link to post
Share on other sites

But lets move in the right direction.

Okay, in the right direction, simply creating a new user would be fastest without waiting for the RunWait to finish

using Run would be more efficient.

to Run one external file would be quicker than running two.

(@comspec is the macro that defines cmd.exe, you are just running cmd twice, while i run it once)

Share this post


Link to post
Share on other sites

If you would read the script more closely, you would notice why there is a run wait. It must wait until the user acount is created (less than a second) before it is able to make the account admin. The second cmd only runs if you need the user to be admin...

why are you arguing with me?

How long did it take your RunWait to finish?... if it took a notable amount of time, you should look into your system issues.

You could probably make the runwait an option that just runs (like you said, without the wait) if the admin parameter is not selected. But if the admin parameter is selected you will NEED the runwait.

The If $admin = 1 runwait could just be changed to a run, but I left it as runwait, just in case somebody tries to create multiple accounts in a loop.

Share this post


Link to post
Share on other sites

Thanks alot, script works


Share this post


Link to post
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
Sign in to follow this  
Followers 0