Sharing folder in Batch file does not share

169 Views Asked by At

First off I am completely new here and pretty new to scripting so hopefully I am not being too stupid but I am trying and keep bumping into a wall here.

What I am trying to do is to make a batch script that creates a folder and then shares this (read/write) Currently what I got is:

mkdir %scanpath% icacls %scanpath% /grant "Everyone":(OI)(CI)F %ext%

Now this does create the folder and in the folder properties it actually does set the correct permission BUT I can not actually get to this folder on the network until I manually go to this folder properties, check the share settings and click the share button. That seems to be the only way to actually propagate the changes.

Of course that is not a huge deal and is easily done but anal as I am I want it to work completely and have spent the last day trying to search for a solution. I mainly looked at the net share command but that doesn't seem to fix the issue either.

I hope you guys have a good way of doing this, all help would be greatly appreciated!

2

There are 2 best solutions below

2
On

There are file and folder permissions, then is the fact if it's shared, then there are share permissions. You have to have all 3. You have only done the first step.

You need to use the net share command to share it and net use to connect to a share.

This sets a share called fred and grant admins full control on the share.

net share fred="C:\Intel" /grant:administrators,Full

PS: Help on net command is a bit unusual as net command /? is short help and net help command is long help.

1
On

it looks like doubling up did the trick, when i did net share and icacls in sequence it suddenly worked. i'll test some more but it looks like i got it. thanks all!