Page 1 of 1 1
Topic Options
#195783 - 2009-09-08 12:12 AM Script that creates folder on File server for users
jojopuppyfish Offline
Fresh Scripter

Registered: 2006-06-26
Posts: 5
I haven't posted here in a long time, so any help pointing me to a script or any help would be appreciated.
What I want to do is write a logon script that checks whether or not there is a user folder on the file server. If not, it will create one there.
Lets call the server PDC

BTW, does this have to be done by an administrator because the user would not have permissions to create a folder on the file server?
Would it be easier to just create a home directory within Active directory?
Any help would be appreciated.

Top
#195784 - 2009-09-08 12:32 AM Re: Script that creates folder on File server for users [Re: jojopuppyfish]
lukeod Offline
Getting the hang of it

Registered: 2008-01-11
Posts: 70
Loc: Australia
Hi jojo

The script is fairly straight forward. Assuming you want the folder to be called the username, the following should work (untested):

 Code:
$sFolder = @USERID
$sServerDir = "\\PDC\Share\"

If Not Exist($sFolder + $sServerDir) ;if the user does not have a directory on the server
	$ = MD($sFolder + $sServerDir)	;make the directory
        "Returned (" + @SERROR + ")" ?  ;Display the result of creating the folder
Else
	;User has a folder on the server. Do nothing
EndIf


Permissions may be an issue. There are a few ways around it, firstly you can set the permissions on the top level of the folder to allow users to create folders. For security purposes, it is best to set these permissions to only apply to 'This Folder Only' (in advanced NTFS permissions). What that does is it only allows users to create folders in the root of that folder.

Assuming that the intention is to give users a private drive (AKA Home drive), using the Home drive path in Active Directory is probably the easiest way to go, it for the most part handles the permission problem itself.

The problem with running it as an administrator is that chances are, permissions on the root folder propagating will prevent the user from writing or maybe even reading from the directory if it is created by an administrative account.


Edited by lukeod (2009-09-08 12:39 AM)

Top
#195790 - 2009-09-08 10:17 AM Re: Script that creates folder on File server for users [Re: jojopuppyfish]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
 Originally Posted By: jojopuppyfish
Would it be easier to just create a home directory within Active directory?
IMHO yes, while creating the user account.

Top
#195791 - 2009-09-08 11:28 AM Re: Script that creates folder on File server for users [Re: Witto]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
Just add the home directory as literally: \\server\share\%username%
Then press apply, and the folder along with appropriate user permissions will be created. (user %username% for this and not the actual username).

Top
#195793 - 2009-09-08 12:05 PM Re: Script that creates folder on File server for users [Re: Arend_]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
If you are worried that there are accounts without home directories, just run a script as an administrator to enumerate all the user accounts and check for the existence of the user's home directory. If it doesn't exist, create it. Should be fairly simple. That way you don't have to worry about users having the correct permission to create shares.
Top
#195950 - 2009-09-18 05:46 PM Re: Script that creates folder on File server for users [Re: BradV]
jojopuppyfish Offline
Fresh Scripter

Registered: 2006-06-26
Posts: 5
So I'm now trying to share the the folder and I keep getting an error for remoteshare.
My syntax is wrong, but I cannot seem to figure out where its wrong.
Any help?

If Not Exist ("\\chi-file-01\users\@USERID")
md "\\chi-file-01\users\@USERID"
Shell '%comspec% /c rmtshare "\\chi-file-01\%USERNAME%$=d:\users\%USERNAME"'
Else
EndIF

Top
#195951 - 2009-09-18 05:47 PM Re: Script that creates folder on File server for users [Re: jojopuppyfish]
jojopuppyfish Offline
Fresh Scripter

Registered: 2006-06-26
Posts: 5
 Originally Posted By: jojopuppyfish
So I'm now trying to share the the folder and I keep getting an error for remoteshare.
My syntax is wrong, but I cannot seem to figure out where its wrong.
Any help?

 Quote:
If Not Exist ("\\chi-file-01\users\@USERID")
md "\\chi-file-01\users\@USERID"
Shell '%comspec% /c rmtshare "\\chi-file-01\%USERNAME%$=d:\users\%USERNAME"'
Else
EndIF


Edited by jojopuppyfish (2009-09-18 05:47 PM)

Top
#195953 - 2009-09-18 07:01 PM Re: Script that creates folder on File server for users [Re: jojopuppyfish]
jojopuppyfish Offline
Fresh Scripter

Registered: 2006-06-26
Posts: 5
I realized that RMTSHARE doesn't work with win2003 very well
I realized that Net Share is the new command I should be using.
Thanks Anyways.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 302 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.059 seconds in which 0.025 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org