Jump to content

VB Script to add local PC user and make an administraor of local PC


Recommended Posts

Posted

I need a script that will add a user 'Training' with a password of 'Course' and make the user a local administrator for some training sessions being put n next week. I need to run this script on a OU so that all the machines in one room get this account.. After the course is finished all PCs will be re-imaged and put solely back on the network.

 

Anyone got a script that can do this?

Posted (edited)

VB script is probably overkill for such a task.

 

Create a bat file containing the following commands:

 

net user Training Course /add

net localgroup administrators Traning /add

 

(this is of the top of my head so you may gave to check the syntax)

 

Add the batch file to the to start up scripts of the machine portion of the group policy.

 

You do not have to rebuild the machines to get rid of the accounts you have created just modify the bat file to:

 

net user Training /delete

 

VB alternative:

 

Dim WshShell, oExec

Set WshShell = CreateObject("WScript.Shell")

Set oExec = WshShell.Exec("net user Training Course /add")

Set oExec = WshShell.Exec("net localgroup administrators Training /add")

Edited by jsnetman
  • Thanks 2
Posted
Dim WshShell, oExec

Set WshShell = CreateObject("WScript.Shell")

Set oExec = WshShell.Exec("net user Training Course /add")

Set oExec = WshShell.Exec("net localgroup administrators Training /add")

 

Sorry to jump on this as well, I have tried this and it works after running twice, is there a way we can put a pause in after adding the training user. I think the script runs too quick to do both at the same time.

 

Also can a passsword be added?

Posted

Dim WshShell, oExec

Set WshShell = CreateObject("WScript.Shell")

Set oExec = WshShell.Exec("net user Training Course /add")

WScript.Sleep(1000)

Set oExec = WshShell.Exec("net localgroup administrators Training /add")

 

wiil pause the script for 1 second

 

The password is included "Set oExec = WshShell.Exec("net user Training Course /add")" adds the user Trainer with a password of Course

  • Thanks 2

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



×
×
  • Create New...