Page 1 of 1

create a user folder and give that user full access to it

Posted: 23 Jul 2009 09:54
by Jarnco31
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.

Posted: 23 Jul 2009 09:58
by Jarnco31
I have a start but I don't know if this is the best way.

@echo off
cls
mkdir G:\user\%name%
set /p name=Name?


any help would be greatly appreciated.

Response

Posted: 29 Jul 2009 05:18
by rfpd
I think that creates a ful-acess paste but is incorrect your code the correct code is:

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

Posted: 31 Jul 2009 04:24
by rfpd
you can use cacls tipe help cacls in cmd.

Posted: 31 Jul 2009 07:48
by dragovian
i'm confused, you want to make a user folder and give the user full access over it ?

so that means you also want to make a user ?

Posted: 31 Jul 2009 07:52
by dragovian
if so then you'd need something in this form

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 )