Automating new user and other stuff input


Recommended Posts

Hello gang,

its been a while but i still have questions.

Now it being the end of the year i have a buch (about 48) new users to put into my system (win2k AD xp clients).

What i want to know is how can i do this automated? Like having an excels or usernames where cetain scripts could run off perhaps?

Thats one issue - but i was wondering now and this is the real pain in thass part of new users.

Is that i have to go into the File server and make a new folder and name it after that user and then give full access to that folder for that user - hence creating a home folder for the user only acdesible by themself and ofcourse IT administration.

Can i do this automated? Im sure big ass companies dont sit there and do this stuf manually.

Cheers fellas

Create a share with secure permissions for users to create home folders:

How to dynamically create security-enhanced redirected folders by using folder redirection in Windows 2000 and in Windows Server 2003

http://support.microsoft.com/default.aspx?...kb;en-us;274443

Create the target folder in the user's context - you can do this with a logon script e.g:

MD \\SERVER\HOME\%USERNAME%

or via Folder Redirection - redirect My Documents to the target folder: e.g. \\SERVER\HOME\%USERNAME%\My Documents

Then in a logon script map the home drive the location created. This way you don't need to add anything to the user properties.

You can also use the same approach listed in the KB article for secure profile folders as well.

Here is what we use to add pupils in our school. First is an example of the text file that is read by the batch file. The username, password and description are seperated by comma's but no spaces. The description makes it handy to find them in active directory afterwards when you sort by that column.

pupil.txt

johnsmith,password,year 10
MarkJones,megatron,year 8
JaneRussell,magic,year 9

AddPupils.bat

@echo on

for /f "tokens=1,2,3 delims=," %%1 in (pupils.txt) do (

:: Add user (net user username,password
:: comment is description - scriptpath is the logon
:: script and profile path is the location of their
:: profile. Only username and password are compulsary'

	net user "%%1" "%%2" /add /comment:%%3 /scriptpath:pupil.bat /profilepath:\\%computername%\profiles$\pupils

:: Make their home folder

	md "d:\users\pupils\%%1"

:: Set permissions on home folder

	cacls "d:\users\pupils\%%1" /G "%%1":F /e
	cacls "d:\users\pupils\%%1" /G Administrators:F /e
	cacls "d:\users\pupils\%%1" /G Managers:F /e
	cacls "d:\users\pupils\%%1" /G Staff:F /e
	cacls "d:\users\pupils\%%1" /E /R Everyone
	cacls "d:\users\pupils\%%1" /E /R Users

:: Add new user to appropriate group

	net group Pupils "%%1" /add

:: Share the user's folder and set permissions

	net share "%%1$"="d:\users\pupils\%%1" /cache:none /grant:"%%1",full /grant:"staff",full /grant:"managers",full /grant:"administrators",full
)

I've just noticed that I should have put quotes around the comment part. Without the quotes it will fail if you have a space in there - which I did in my example :blush:

So that line should be:

 net user "%%1" "%%2" /add /comment:"%%3" /scriptpath:pupil.bat /profilepath:\\%computername%\profiles$\pupils

One other thing might be worth considering. You will see that we've given the user full control to his own folder, which you might think makes sense. Unfortunately, that means they can take ownership of files and folders in there, so sometimes either deliberately or by accident they will make themselves the owner and remove the rights of the administrator etc. That is very easy to get back, of course, but it can mean that *some* types of backup will then skip the guy's files because it doesn't have access to the folder.

To solve this, we now only give the user read,write,change access to his folder so he now doesn't have the ability to take ownership OR remove other people's rights. Change the first 'cacls' line in batch file as follows if you want to make this happen

 cacls "d:\users\pupils\%%1" /G "%%1":R /e
 cacls "d:\users\pupils\%%1" /G "%%1":W /e
 cacls "d:\users\pupils\%%1" /G "%%1":C /e

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Microsoft is busy. Lots of changes to be released imminently for Windows server or soon. Also, lots happening for next version as well. Third party virus scanning software is being moved out of Kernel mode to avoid repeat of Crowdstrike incident. Windows Protected Mode and Windows Ready Print no longer require third party print drivers to be installed. New storage stack being developed. New NVME drivers now available for Windows Server 2025 to improve local NVME drive performance by 60+ percent. NVME-Of of fabric being worked on for next release to improve network access to NVME drives. ReFs (next file system) now has ability to boot and will become default file system in next release of Windows Server. ReFs improves on NTFS in several areas including resiliency and reliability and scalability. New update stack is being worked on to unify Windows updates, and updates for drivers and first party/3rd party application software. A stricter and more robust third-party driver certification program (ODI) is being worked on to improve performance, thermals, battery life, and reliability on modern Windows hardware by tightening how OEMs and IHVs (Intel, AMD, Qualcomm, NVIDIA, etc.) build and ship drivers. There is a tone more but too numerous to mention.
    • Now disable that stupid OneDrive backup request when Windows starts please. So unbelievably frustrating to only have “remind me later” instead of “no and never ask me again”
    • Hello, The Media Creation Tool is still at v10.0.26100.7019 from October 2025. Just looks like the backend has been updated. Regards, Aryeh Goretsky
    • Since they open sourced the calculator in Win 10/11 it is much better and can do a lot, I love it.
    • That's just silly imo. The lengths that man goes to just to avoid W11 is just nuts. Very, very few home users would do that. I will say this though, he is committed. Btw, I note on askwoody that Woody Leonhard passed away March, 2025 aged 73. His site was one of my favorites back in the day. Belated yes but RIP Woody.
  • Recent Achievements

    • One Month Later
      Markus94287 earned a badge
      One Month Later
    • Week One Done
      Markus94287 earned a badge
      Week One Done
    • One Year In
      Markus94287 earned a badge
      One Year In
    • Dedicated
      truespursfan earned a badge
      Dedicated
    • Rookie
      restore went up a rank
      Rookie
  • Popular Contributors

    1. 1
      +primortal
      508
    2. 2
      +Edouard
      169
    3. 3
      PsYcHoKiLLa
      154
    4. 4
      ATLien_0
      90
    5. 5
      Steven P.
      79
  • Tell a friend

    Love Neowin? Tell a friend!