Jump to content

Recommended Posts

Posted

Hello,

 

I run a workgroup of computers with something like 90 users. All home drives and areas are all stored on a NAS. I would much rather run a domain although we don't have the money or time to maintain this so for the foreseeable future were using workgroups. My only problem with workgroups is managing users. I would like to create a batch script that is scheduled at startup to load any new users created onto the computer. Although I'm not sure on how to achieve this. I also would need to assign Staff to their extra group.

 

Thanks in advance.

Posted (edited)

Not entirely sure what you mean here.

 

is it, you want to create a local account on every PC, based on a 'list' of users - perhaps a text file somewhere?

Or, do you mean, create a list of user accounts on a particular PC and store that somewhere?

 

You know, a domain controller wouldn't take too much setting up, and you could pretty much use a regular PC if you had to.

Edited by mrwoberts
Posted

Okay, is this what you want to do?

I'm not including the part where you fetch the text file and compare the users against the desired users list...

 

LAPTOP-012 (Existing user accounts)

Fred (administrators)

Bob (users)

Jenny (users)

Sally (administrators)

 

You want to create two new users on that PC, one admin, the other a standard user...

Tony (administrators)

Matthew (users)

 

To do that you would issue the following commands...

net user /add Tony 
net user /add Matthew 
net localgroup Administrators Tony /add

 

That would be the batch script way, but a VB or Powershell script would probably be better.

Here's a VB script for example...

Posted

I've tried the following, @echo off

net localgroup /add Staff

net localgroup Staff TestUser1 password /add

net localgroup Staff TestMeNow1 password2 /add

 

When I ran as admin on one of the machines it closed straight away. However tomorrow I will attempt using a powershell script.

Posted (edited)
When I ran as admin on one of the machines it closed straight away. However tomorrow I will attempt using a powershell script

 

You need to place a

pause

at the end of your script, otherwise it will close straightaway - the command is not very difficult for the PC so it finishes almost instantly.

If you'd rather it just waited for ten seconds then closed, then add this instead

timeout /t 10

 

On closer inspection, you're not actually adding the users TestUser1, or TestMeNow1, like I showed you above. All you've done is create a group then tried to add two (existing) users to it. Is that what you wanted?

Edited by mrwoberts
Posted (edited)

Here is the correct version of your script

 

@echo off
REM ## Create a new Staff group ##
net localgroup /add Staff

REM ## Create two new users ##
net user TestUser1 password  /add 
net user TestMeNow1 password2 /add

REM ## Add new users to the Staff group ##
net localgroup Staff TestUser1 /add
net localgroup Staff TestMeNow1 /add

pause

Edited by mrwoberts

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...