Re: How do I change default permissions for shares?

From: Torgeir Bakken (MVP) (Torgeir.Bakken-spam_at_hydro.com)
Date: 11/28/03


Date: Fri, 28 Nov 2003 01:55:18 +0100

killme wrote:

> On Thu, 27 Nov 2003 21:40:27 +0100, Torgeir Bakken (MVP) says...
> >
> > Use a script (batch\vbscript) to create the share and set the permissions
> > [SNIP]
>
> I want to be able to do this from within Explorer. Doing a batch would mean
> doing it all at once, but I add shares throughout the week and if I could
> change the default permissions as the share is created then I wouldn't have
> to do it manually after every share I create. Using a script would still
> mean me having to type out the permissions and the shares to create and I
> would have to do it each time I created a share.

Hi

No, you can create a vbscript or batch file that supports "drag-and-drop" from
Explorer so the only thing you need to is type in the share name the script
asks for. If your share name is always the folder name or the folder name with
$ behind, you can even let the vbscript or the batch file extract the last
folder name from the path that was sent as input to the script (or you can have
two scripts, one that asks for the share name and one that extracts it).

So if you place this script on the desktop, you just drag the folder up on the
file and you will be asked for the share name (if it is not created
automatically), or even better put the script in the SendTo folder, so you can
just right click on the folder and use the 'Send To' menu entry. More easy than
that you can't create a share (unless you get someone else to do the job for
you ;-)

I have created a batch file for you that support the folder as input parameter
(drag and drop/Send To), and asks for a share name when activated. It uses
RMTSHARE.EXE to create the share and set the current user to have FULL control
(Everyone none). The script will list the result before it ends.

Download RMTSHAR.EXE from here and unpack it:
ftp://ftp.microsoft.com/bussys/winnt/winnt-public/reskit/nt40/i386/

If you don't put RMTSHARE.EXE in the path (e.g. in the windows folder), you
need to hard code the path to RMTSHARE.EXE in the batch file below (two
places).

Here is CreateShare.bat (I have tested it on Windows XP):

@echo off
echo.
set /p ShareName=Enter share name:
echo.
@echo on
RMTSHARE.EXE \\%COMPUTERNAME%\"%ShareName%"=%1 /GRANT %USERNAME%:f
@echo off
echo.
echo.
RMTSHARE.EXE \\%COMPUTERNAME%\"%ShareName%"
echo.
pause

If the folder is on a remote server, you will need to substitute
%COMPUTERNAME%, and if the %USERNAME% doesn't work, you might need to change it
to %USERDOMAIN%\%USERNAME%

--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter


Relevant Pages

  • Re: Returning a value from a VBScript
    ... VBScript for use by another script, batch file, or other command. ... echo MyScript.vbs returned an ErrorLevel of %ErrorLevel% ...
    (microsoft.public.scripting.vbscript)
  • Re: How to STOP file - a command line & script - where do you put it to work?
    ... That batch is for a very specific problem. ... that in and tell it which folders to change the names in? ... I'm a PC user, not a software, java or script> writer. ... > This is the script that was given: > @echo off ...
    (microsoft.public.windowsxp.general)
  • Re: How to STOP file - what is a command line & script?
    ... That batch is for a very specific problem. ... I'm a PC user, not a software, java or script writer. ... > @echo off ... > type nul> %temp%.\process.bat ...
    (microsoft.public.windowsxp.general)
  • Re: bat file help
    ... I need that script to be able to eject the ... current DVD and ask for a new one. ... :: Prime the counter used to accumulate folder sizes ... echo Please insert a new DVD! ...
    (microsoft.public.windowsxp.general)
  • Re: Problems with require_once() and directory structure
    ... Each folder contains one or more files. ... echo "In script\n"; ... "In script Got here Attempting to instantiate db object " ... why I can't seem to use my directory structure. ...
    (alt.php)