From: francois on
Hi everybody,

I would like to create a function in vbs like this :


---------------------------------------
createFolder(path, rights, share, shareName)

where :

* "path" is a local path (ok) or a UNC path like \\PC\share
(here is the problem)

* "right" is a string which sets the NTFS rights

* "share" is boolean (True or False). If it is True the
folder is shared, if not the folder is not shared.

* "shareName" is the name of the share (if the folder is shared)
---------------------------------------


My problem is when the path is a UNC path. If it's a local
path, I can make my script with the .Run method and "cacls"
and "net share" commands. But if "path" is a UNC path, it
doesn't work because :

* "cacls \\SRV\d$\Myfolder ....."
* "net share shareName="\\SRV\d$\Myfolder" /UNLIMITED"

do not seem to work. These commands need a local path, I assume.

How can we do to solve the problem? I add that I want to use
the script as the domain administrator.

Thanks in advance


--
Fran�ois Lafont
From: Pegasus [MVP] on


"francois" <francois(a)NoSpam.fr> said this in news item
news:#J1nhMSoKHA.5520(a)TK2MSFTNGP05.phx.gbl...
> Hi everybody,
>
> I would like to create a function in vbs like this :
>
>
> ---------------------------------------
> createFolder(path, rights, share, shareName)
>
> where :
>
> * "path" is a local path (ok) or a UNC path like \\PC\share (here is the
> problem)
>
> * "right" is a string which sets the NTFS rights
>
> * "share" is boolean (True or False). If it is True the folder is shared,
> if not the folder is not shared.
>
> * "shareName" is the name of the share (if the folder is shared)
> ---------------------------------------
>
>
> My problem is when the path is a UNC path. If it's a local path, I can
> make my script with the .Run method and "cacls" and "net share" commands.
> But if "path" is a UNC path, it doesn't work because :
>
> * "cacls \\SRV\d$\Myfolder ....."
> * "net share shareName="\\SRV\d$\Myfolder" /UNLIMITED"
>
> do not seem to work. These commands need a local path, I assume.
>
> How can we do to solve the problem? I add that I want to use the script as
> the domain administrator.
>
> Thanks in advance
>
>
> --
> Fran�ois Lafont

You could use the trusty old psexec.exe utility from www.sysinternals.com.

From: Jens Hastrup on
Hi,

The CACLS stuff should work just fine with UNC
Use rmtshare.exe
ftp://ftp.microsoft.com/bussys/winnt/winnt-public/reskit/nt40/i386/RMTSHAR.EXE
for the remote share and share rights

Jens

"francois" <francois(a)NoSpam.fr> skrev i en meddelelse
news:%23J1nhMSoKHA.5520(a)TK2MSFTNGP05.phx.gbl...
> Hi everybody,
>
> I would like to create a function in vbs like this :
>
>
> ---------------------------------------
> createFolder(path, rights, share, shareName)
>
> where :
>
> * "path" is a local path (ok) or a UNC path like \\PC\share (here is the
> problem)
>
> * "right" is a string which sets the NTFS rights
>
> * "share" is boolean (True or False). If it is True the folder is shared,
> if not the folder is not shared.
>
> * "shareName" is the name of the share (if the folder is shared)
> ---------------------------------------
>
>
> My problem is when the path is a UNC path. If it's a local path, I can
> make my script with the .Run method and "cacls" and "net share" commands.
> But if "path" is a UNC path, it doesn't work because :
>
> * "cacls \\SRV\d$\Myfolder ....."
> * "net share shareName="\\SRV\d$\Myfolder" /UNLIMITED"
>
> do not seem to work. These commands need a local path, I assume.
>
> How can we do to solve the problem? I add that I want to use the script as
> the domain administrator.
>
> Thanks in advance
>
>
> --
> Fran�ois Lafont


From: Al Dunbar on


"francois" <francois(a)NoSpam.fr> wrote in message
news:#J1nhMSoKHA.5520(a)TK2MSFTNGP05.phx.gbl...
> Hi everybody,
>
> I would like to create a function in vbs like this :
>
>
> ---------------------------------------
> createFolder(path, rights, share, shareName)
>
> where :
>
> * "path" is a local path (ok) or a UNC path like \\PC\share (here is the
> problem)
>
> * "right" is a string which sets the NTFS rights
>
> * "share" is boolean (True or False). If it is True the folder is shared,
> if not the folder is not shared.
>
> * "shareName" is the name of the share (if the folder is shared)
> ---------------------------------------

As a suggestion, why not delete the "share" parameter? If the sharename
parameter is a string, then share the folder using that name. If it is a
boolean like "false", then don't share.

> My problem is when the path is a UNC path. If it's a local path, I can
> make my script with the .Run method and "cacls" and "net share" commands.
> But if "path" is a UNC path, it doesn't work because :
>
> * "cacls \\SRV\d$\Myfolder ....."
> * "net share shareName="\\SRV\d$\Myfolder" /UNLIMITED"
>
> do not seem to work. These commands need a local path, I assume.

CACLS doesn't need a local path, it just needs you to be an admin on "SRV",
which, as domain admin, you should be. If you have that right, then perhaps
there is something wrong with the other parameters in your cacls command.

net share does need a local (not mapped) path, but, on what computer do you
want to create the share? It should be on the computer on which the folder
is local. try doing it this way:

net share \\SRV shareName="d:\Myfolder" /UNLIMITED

also note that "sharename" should not be literal, but be replaced by the
desired name of the share you want to create.

/Al

> How can we do to solve the problem? I add that I want to use the script as
> the domain administrator.
>
> Thanks in advance
>
>
> --
> Fran�ois Lafont

From: francois on
Jens Hastrup a �crit :

> The CACLS stuff should work just fine with UNC

Oops! You are right. I probably was tired when I made tests.
Sorry.

> Use rmtshare.exe
> ftp://ftp.microsoft.com/bussys/winnt/winnt-public/reskit/nt40/i386/RMTSHAR.EXE
> for the remote share and share rights

Thanks for the link, but I think I'm going to choose the
"psexec" command which I find very good.



--
Fran�ois Lafont