We help IT Professionals succeed at work.

Script to create local admin user

murryc
murryc asked
on
I need a script that determines what domain user is correctly logged in, then creates a local admin for that user.  The users are non-admin in the domain, but they need to be a local domain so that I can make some system tweaks under their profile that require admin privileges.  I then need a script that deletes the local admin user for that domain user as I will need to remove the local account after the tweaks have been completed.
Comment
Watch Question

Chris HInfrastructure Manager

Commented:
What OS?
Infrastructure Manager
Commented:
I hate VB when a batch file will do it.

Batch file 1
set /p pass=Type a Password
net user /add %username% %pass%
net localgroup administrators %username% /add

Batch file 2
net user /delete %username%

Author

Commented:
Windows 7 Pro

I am all for batch files or VB scripts.  Whatever works.

I don't think this batch will add the current logged in user as a local admin though.  There is no need to give it a password as the user is domain existing and so we are just adding them as a local user.  This will be executed on a domain environment.
Chris HInfrastructure Manager

Commented:
It worked fine, see attached file....
Untitled.png
Chris HInfrastructure Manager

Commented:
AND ALWAYS PASSWORD PROTECT ADMIN ACCOUNTS.

Sorry, that was my old tech instructor yelling at both of us.
Chris HInfrastructure Manager

Commented:
Whoops, wrong pic, this one...
Untitled.png