0

I am making a simple script for a network where ever a homefolder is created for every user. Making the users + putting them in the correct group works perfectly but as soon as I add the homefolder part it only executes once. This script is called 9 times in another script but it only works once.

rem ****** %1 username
rem ****** %2 password
rem ****** %3 group



net user %1 %2 /ADD 
net user %1 /logonpasswordchg:no 
net user %1 /active:yes 
net user %1 /expires:NEVER 
net user %1 /times:M-F,8-18
net user %1 /passwordchg:no

net group %3 %1 /add


C:
cd \School\Homefolders\Leerlingen
md %1
echo Y| cacls C:\School\Homefolders\Leerlingen\%1 /G %1:C administrators:F
cd..
cd..
cd..
cd..
C:
5
  • Which HomeFolders line is it? There are 2... Commented Dec 6, 2012 at 10:18
  • The 2nd line is for the permissions on the homefolder? Commented Dec 6, 2012 at 10:19
  • Yeah, but you didn't specify the line where it was causing problems. The 1st line I presume then? Commented Dec 6, 2012 at 10:21
  • That is the problem i don't know what is causing it not to redo the code. The other script with the call works, I have tested that multiple times. So even with "echo Y| cacls C:\School\Homefolders\Leerlingen\%1 /G %1:C administrators:F" left out the script does exactly the same. It creates a folder 1 time and then it just stops. Commented Dec 6, 2012 at 10:23
  • Ok. If the problem is with the cd line it could be it's not actually changing to the right drive. The line that says C: won't actually do anything, try using cd /d C: instead and see if that works. Commented Dec 6, 2012 at 10:32

1 Answer 1

1

I just created a similar example and had the same problem caused by changing the directories. You also have an extra "cd .." statement. Try just using the following:

md C:\School\Homefolders\Leerlingen\%1
echo Y| cacls C:\School\Homefolders\Leerlingen\%1 /G %1:C administrators:F

I'm also assuming as it otherwise gets called multiple times that you've remembered to use a call statement in the batch file that calls that one.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.