create a user folder and give that user full access to it
Moderator: DosItHelp
create a user folder and give that user full access to it
First of all I am new to batch files. I need to create a batch file that will allow me to create a user folder in a specified location and give that user full access to only there folder and not the other users folders.
Response
I think that creates a ful-acess paste but is incorrect your code the correct code is:
because if you put the variable before the mkdir it can understand but if you put after it makes no sentence!
Code: Select all
@echo off
cls
set /p name=Name?
mkdir G:\user\%name%
because if you put the variable before the mkdir it can understand but if you put after it makes no sentence!
cacls
you can use cacls tipe help cacls in cmd.
if so then you'd need something in this form
and rfpd is right always declare the variable before using it .
it's like trying to get money from an ATM before inserting your credit card and typing in your pincode
do say something if it worked or not. ( cause i'm working on linux sabayon atm and can't try myself )
note : the mkdir Music up till mkdir Documents, including the pushd and popd line and, but they make the standard "user" folders.
the /T will give the same control as you have on the folder, to subdirectories of that folder. ( some call it inheritance, i call it MAGIC )
Code: Select all
@echo off
cls
set /p name=Name?
net user /add %name%
mkdir c:\users\%name%
pushd c:\users\%name%
mkdir Music
mkdir Pictures
mkdir Documents
popd
icacls c:\users\%name% /grant %name%:(F) /T
timeout -1
and rfpd is right always declare the variable before using it .
it's like trying to get money from an ATM before inserting your credit card and typing in your pincode
do say something if it worked or not. ( cause i'm working on linux sabayon atm and can't try myself )
note : the mkdir Music up till mkdir Documents, including the pushd and popd line and, but they make the standard "user" folders.
the /T will give the same control as you have on the folder, to subdirectories of that folder. ( some call it inheritance, i call it MAGIC )