Page 1 of 1 1
Topic Options
#19803 - 2002-04-11 06:32 PM Share a folder
AnalogKid2112 Offline
Fresh Scripter

Registered: 2002-04-09
Posts: 11
Loc: Hamilton Ontario, Canada
I have # users and I'm lazy. I wrote a piece of code in my .scr file that checks to see if the current user has a folder (which will eventually be his/her HomeDir) on the server and if the folder doesn't yet exist the script will create the folder - that works! But in order to properly set that folder as the users HomeDir the folder must be shared and I don't want to have to manually share everything. Is there a way of programatically sharing a folder? KIX, DOS, whatever.
_________________________
Is that going to be on the test?

Top
#19804 - 2002-04-11 06:47 PM Re: Share a folder
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
LAZY... Les, someone's trying to take your old monikor [Eek!]

Okay, take a look here on doing some BATCH file stuff for this.

Moving Users and Permissons

Don't forget to look at the other links by Kent at the bottom for more information on another thread.

UPDATE -
Well, never mind. sealeopard went ahead and wrote the script for you... As long as your users have rights there. Scary if they do.

[ 11 April 2002, 19:17: Message edited by: NTDOC ]

Top
#19805 - 2002-04-11 06:51 PM Re: Share a folder
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Yeah, my fav saying is "laziness is the mother of invention" but in this case I think the fetus aborted. [Big Grin]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#19806 - 2002-04-11 06:55 PM Re: Share a folder
Anonymous
Unregistered


Hmmm ... don't you have a problem with user rights here? I mean - the users wouldn't have permissions to share the folder anyway?

Why not make a script that you run as Administrator ... testing if the user have a homedir or not.

Try this on the command prompt ...

net help share

Top
#19807 - 2002-04-11 06:57 PM Re: Share a folder
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
AKid,

checkout the Resource Kit tool rmtshare.exe

Fits perfect for yer needs

J.

(too lazy to give an example [Big Grin] )
_________________________



Top
#19808 - 2002-04-11 07:08 PM Re: Share a folder
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Jens grabs into his magic hat, and... pulls out a rabbit script:
code:
  $username='whatever'
$userdir='d:\users\'+$username
$rmtsharebin='rmtshare.exe'
$caclsbin='cacls.exe'

if not exist($userdir)
? 'Creating user directory for user '+$username
md $userdir
endif

? 'Setting permissions on personal directory for user '+$username

$shellcommand='echo y| '+$caclsbin+' "'+$userdir+'" /T /C /G Administrators:f "'+$username+'":c'
shell '%COMSPEC% /e:1024 /C '+$shellcommand

? 'Creating hidden network share for personal directory'
$shellcommand=$rmtsharebin+' \\SERVER\"'+$username+'$$"="e:\users\'+$username+'" /unlimited'
$shellcommand=$shellcommand+' /remark:"private home directory"'
$shellcommand=$shellcommand+' /grant "'+$username+'":c'
shell '%COMSPEC% /e:1024 /C '+$shellcommand

_________________________
There are two types of vessels, submarines and targets.

Top
#19809 - 2002-04-11 07:43 PM Re: Share a folder
Rocco Capra Offline
Hey THIS is FUN
*****

Registered: 2002-04-01
Posts: 380
Loc: Mansfield Ohio
Uh...If this is an NT domain this is built right into User Manager. [Confused]

Are you not on an NT domain??

Rocco

Oh I see your looking at sharing each individual user's home folder. Nevermind my babble obve then. [ think before you type, Rocco ]

We have over 1300 users on our network, with the bigges site at around 400 users. I don't think I am going to ever share each user's folder. [Razz]

[ 11 April 2002, 21:50: Message edited by: Rocco Capra ]
_________________________
I Love this board!! -------------------- My DEV PC is running KIX 4.22 WINXP Pro

Top
#19810 - 2002-04-11 08:33 PM Re: Share a folder
Anonymous
Unregistered


Might want to check out a product called AutoShare.

It is GUI configurable and runs as a service on the NT server where your user home directories are. It automatically applies the correct NTFS permissions and then shares each user home directory (when it detects new ones).

Set it and forget it.

You can download a copy from http://www.scriptlogic.com/autoshare

-Brian

Top
#19811 - 2002-04-11 11:43 PM Re: Share a folder
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
AnalogKid2112, Brian, and others...

You should also be able to do that with this little tid bit as well. Using this freebie and some of your own code, you should be able to mangage the same functionality. Being that I don't have that much of a need for something like that, I won't spend the time to even try coding it up, but hey... if you need it and your Finanace dept. won't spring for it, you can now write your own.

ASCI's File System Event Provider for WMI

[ 11 April 2002, 23:44: Message edited by: NTDOC ]

Top
#19812 - 2002-04-12 06:41 AM Re: Share a folder
AnalogKid2112 Offline
Fresh Scripter

Registered: 2002-04-09
Posts: 11
Loc: Hamilton Ontario, Canada
Thanks for the script sealeopard but I'm getting an error when the script reaches this:
shell '%COMSPEC% /e:1024 /C '+$shellcommand

I'm not really sure what to do here! help??
[Confused]
_________________________
Is that going to be on the test?

Top
#19813 - 2002-04-12 08:59 AM Re: Share a folder
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Jens,

Not doubting you, but did you verify all those single and double quote things work on all lines and on NT and 2000?

AnalogKid,
What is the specific error you get back?
I'm telling you though, sharing with a DOS batch file as shown will be over and done in only about a minute. Heck, and if you don't like the results you can hilight all of them in the GUI and delete them, or from the Registry.

I don't have time to double check Jens code, but normally his stuff works pretty well. Are you sure your code is copied correctly and looks like it is here on the board?

Top
#19814 - 2002-04-12 01:11 PM Re: Share a folder
AnalogKid2112 Offline
Fresh Scripter

Registered: 2002-04-09
Posts: 11
Loc: Hamilton Ontario, Canada
The code it copied exactly as is on his post. I checked it 9 or 10 times over and tried moving the quotes around to.

The error I'm letting is BAD COMMAND OR FILE NAME.
It's only a guess but I think it's refering to
%COMSPEC%, but that's only my guess.
_________________________
Is that going to be on the test?

Top
#19815 - 2002-04-12 03:39 PM Re: Share a folder
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
NTDOC:

I'm sure the code I posted is okay becasue it's the production code in my automated shared user folders creations cript.

AnalogKid2112:
Of cource you will need to adapt the code to your environment.
$username mustr be set to the username that you want to create the directory for
$userdir is the local directory that will become the user directory
$rmtsharebin is the complete path to RMTSHARE.EXE including double quotes if theere are spaces in the pathname
$caclsbin is the complete path to CACLS.EXE including double quotes if theere are spaces in the pathname
%COMSPEC% is a DOS variable that gets resolved to the command interpreter, e.g. c:\winnt\system32\cmd.exe on Windows NT

If you modify the script by inserting
code:
? $shellcommand

in the line above each SHELL command, it'll print out the contents of the $shellcommand variable. Make sure that the pathnames for the .EXEs are correct and post the contects of $shellcommand. I can then take a look and see what might be wrong. I am suspecting that you don't reference the two .EXEs correctly and the script can't find them which would explain the error.
_________________________
There are two types of vessels, submarines and targets.

Top
#19816 - 2002-04-12 03:50 PM Re: Share a folder
bleonard Offline
Seasoned Scripter
*****

Registered: 2001-01-19
Posts: 581
Loc: Chicago, IL
Why not create this share at creation of the Domain user account? Tools exist such as UserManageNT from Tools4ever.com (5-user Lite version avail at no charge). This can create shares, group memberships, Exchange accounts, force consistent username syntax, etc. for multiple accounts and multiple domains. Seems to me by the time a user can log onto your network these items should already be in place.
Bill

Top
#19817 - 2002-04-12 05:21 PM Re: Share a folder
Anonymous
Unregistered


Here's a batch file to create a list of users folders and share them

net use n: /d /yes
net use n: \\servername\f$
n:
cd users
for /f %%x in (n:\users.txt) do md %%x >>n:\dir.log
for /f %%x in (n:\users.txt) do cacls %%x /e /g domain\%%x:c >>n:\perms.log
for /f %%x in (n:\users.txt) do rmtshare \\servername\%%x$=f:\users\%%x /grant domain\%%x:change /grant system:"full control" /grant administrators:"full control" >>n:\share.log
c:
net use n: /d

syntax for user.txt

user1
user2
user3
etc

the batch file will just loop until in reaches the end of the text file

P.S if you have the folder above assigned with the correct permissions
i.e administrator full control, the batch file adds the user's permission

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 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.076 seconds in which 0.037 seconds were spent on a total of 12 queries. Zlib compression enabled.

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