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

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Jarnco31
Posts: 2
Joined: 23 Jul 2009 09:48

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

#1 Post by Jarnco31 » 23 Jul 2009 09:54

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.

Jarnco31
Posts: 2
Joined: 23 Jul 2009 09:48

#2 Post by Jarnco31 » 23 Jul 2009 09:58

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.

rfpd
Posts: 78
Joined: 06 Jul 2009 16:19
Location: Lisbon, Portugal
Contact:

Response

#3 Post by rfpd » 29 Jul 2009 05:18

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!

rfpd
Posts: 78
Joined: 06 Jul 2009 16:19
Location: Lisbon, Portugal
Contact:

cacls

#4 Post by rfpd » 31 Jul 2009 04:24

you can use cacls tipe help cacls in cmd.

dragovian
Posts: 17
Joined: 30 Jul 2009 09:43
Location: Belgium - Leuven
Contact:

#5 Post by dragovian » 31 Jul 2009 07:48

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 ?

dragovian
Posts: 17
Joined: 30 Jul 2009 09:43
Location: Belgium - Leuven
Contact:

#6 Post by dragovian » 31 Jul 2009 07:52

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 )

Post Reply