I have about 300 shared folders that I need to have the path changed because
we the folders are getting moved to another drive. I can list and create
shares, but cannot figure out how to change the path of an existing share. I
get an error when I try to change it. Can this be done with VBScript or is
there another tool I can use?

Please help,

Rick
==================================
Creating share:

Set FservObj = GetObject("WinNT://ComputerName/lanmanserver")

set newshare = FservObj.create("fileshare","test")
newshare.path = "C:\temp"
newshare.setinfo
Set newshare = nothing

=====================================
Listing Share info:

Set FS = GetObject("WinNT://stretch2400/LanmanServer/Test1")
Wscript.Echo vbtab & fs.Path
Wscript.Echo vbtab & fs.MaxUserCount
Wscript.Echo vbtab & fs.AdsPath
Wscript.Echo vbtab & fs.Path
Wscript.Echo vbtab & fs.Class
Wscript.Echo vbtab & fs.CurrentUserCount
Wscript.Echo vbtab & fs.description
Wscript.Echo vbtab & fs.GUID
Wscript.Echo vbtab & fs.HostComputer
Wscript.Echo vbtab & fs.Parent
Wscript.Echo vbtab & fs.Schema
' *** This is where I get the error.
' FS.Path = "C:\Scripts"
' FS.SetInfo
' Wscript.Echo vbtab & fs.Path

Re: Change a shared folder path? by Brandon

Brandon
Sun Feb 20 23:15:13 CST 2005



Rick Voland wrote:

> I have about 300 shared folders that I need to have the path changed because
> we the folders are getting moved to another drive. I can list and create
> shares, but cannot figure out how to change the path of an existing share. I
> get an error when I try to change it. Can this be done with VBScript or is
> there another tool I can use?
>

what error do you get?

>
> Please help,
>
> Rick
> ==================================
> Creating share:
>
> Set FservObj = GetObject("WinNT://ComputerName/lanmanserver")
>
> set newshare = FservObj.create("fileshare","test")
> newshare.path = "C:\temp"
> newshare.setinfo
> Set newshare = nothing
>
> =====================================
> Listing Share info:
>
> Set FS = GetObject("WinNT://stretch2400/LanmanServer/Test1")
> Wscript.Echo vbtab & fs.Path
> Wscript.Echo vbtab & fs.MaxUserCount
> Wscript.Echo vbtab & fs.AdsPath
> Wscript.Echo vbtab & fs.Path
> Wscript.Echo vbtab & fs.Class
> Wscript.Echo vbtab & fs.CurrentUserCount
> Wscript.Echo vbtab & fs.description
> Wscript.Echo vbtab & fs.GUID
> Wscript.Echo vbtab & fs.HostComputer
> Wscript.Echo vbtab & fs.Parent
> Wscript.Echo vbtab & fs.Schema
> ' *** This is where I get the error.
> ' FS.Path = "C:\Scripts"
> ' FS.SetInfo
> ' Wscript.Echo vbtab & fs.Path


Re: Change a shared folder path? by Roland

Roland
Mon Feb 21 04:09:15 CST 2005

"Rick Voland" wrote in message
news:AE23DD09-7BAD-4215-9B61-EDC45B2918AE@microsoft.com...
:I have about 300 shared folders that I need to have the path changed
because
: we the folders are getting moved to another drive. I can list and create
: shares, but cannot figure out how to change the path of an existing share.
I
: get an error when I try to change it. Can this be done with VBScript or
is
: there another tool I can use?

I don't think you can change the path of an existing share. I think if you
want to reuse that share, you have to delete it and then recreate it setting
the new path. If it is possible to just modify the path, I haven't figured
out a way to do it.

Dim fs, share, sharePath, ns, computerName, sh
' Written by Roland Hall - http://kiddanger.com/
computerName = "myComputer"
share = "myShare"
sharePath = "c:\mySharePath"

wscript.echo "Modifying share path..."
Set fs = GetObject("WinNT://" & computerName & "/LanmanServer")
for each sh in fs
if sh.name = share then
wscript.echo "Share:" & sh.name
wscript.echo "oldPath: " & sh.path
fs.delete "fileshare", share
fs.SetInfo
end if
next
set ns = fs.create("fileshare", share)
ns.path = sharePath
ns.SetInfo
wscript.echo "newPath: " & ns.path

Set fs = Nothing
Set ns = Nothing

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp



Re: Change a shared folder path? by RickVoland

RickVoland
Mon Feb 21 08:33:01 CST 2005

The error I get is:
Modify Share.vbs(14, 5) Active Directory: The specified directory property
is not supported.

"Brandon McCombs" wrote:

>
>
> Rick Voland wrote:
>
> > I have about 300 shared folders that I need to have the path changed because
> > we the folders are getting moved to another drive. I can list and create
> > shares, but cannot figure out how to change the path of an existing share. I
> > get an error when I try to change it. Can this be done with VBScript or is
> > there another tool I can use?
> >
>
> what error do you get?
>
> >
> > Please help,
> >
> > Rick
> > ==================================
> > Creating share:
> >
> > Set FservObj = GetObject("WinNT://ComputerName/lanmanserver")
> >
> > set newshare = FservObj.create("fileshare","test")
> > newshare.path = "C:\temp"
> > newshare.setinfo
> > Set newshare = nothing
> >
> > =====================================
> > Listing Share info:
> >
> > Set FS = GetObject("WinNT://stretch2400/LanmanServer/Test1")
> > Wscript.Echo vbtab & fs.Path
> > Wscript.Echo vbtab & fs.MaxUserCount
> > Wscript.Echo vbtab & fs.AdsPath
> > Wscript.Echo vbtab & fs.Path
> > Wscript.Echo vbtab & fs.Class
> > Wscript.Echo vbtab & fs.CurrentUserCount
> > Wscript.Echo vbtab & fs.description
> > Wscript.Echo vbtab & fs.GUID
> > Wscript.Echo vbtab & fs.HostComputer
> > Wscript.Echo vbtab & fs.Parent
> > Wscript.Echo vbtab & fs.Schema
> > ' *** This is where I get the error.
> > ' FS.Path = "C:\Scripts"
> > ' FS.SetInfo
> > ' Wscript.Echo vbtab & fs.Path
>
>

Re: Change a shared folder path? by RickVoland

RickVoland
Mon Feb 21 08:53:02 CST 2005

If I have to delete the share and then recreate it, I need to make sure it
has the same permissins that it had before it was deleted. Any Ideas on how
to preserve the original share permissions?

"Roland Hall" wrote:

> "Rick Voland" wrote in message
> news:AE23DD09-7BAD-4215-9B61-EDC45B2918AE@microsoft.com...
> :I have about 300 shared folders that I need to have the path changed
> because
> : we the folders are getting moved to another drive. I can list and create
> : shares, but cannot figure out how to change the path of an existing share.
> I
> : get an error when I try to change it. Can this be done with VBScript or
> is
> : there another tool I can use?
>
> I don't think you can change the path of an existing share. I think if you
> want to reuse that share, you have to delete it and then recreate it setting
> the new path. If it is possible to just modify the path, I haven't figured
> out a way to do it.
>
> Dim fs, share, sharePath, ns, computerName, sh
> ' Written by Roland Hall - http://kiddanger.com/
> computerName = "myComputer"
> share = "myShare"
> sharePath = "c:\mySharePath"
>
> wscript.echo "Modifying share path..."
> Set fs = GetObject("WinNT://" & computerName & "/LanmanServer")
> for each sh in fs
> if sh.name = share then
> wscript.echo "Share:" & sh.name
> wscript.echo "oldPath: " & sh.path
> fs.delete "fileshare", share
> fs.SetInfo
> end if
> next
> set ns = fs.create("fileshare", share)
> ns.path = sharePath
> ns.SetInfo
> wscript.echo "newPath: " & ns.path
>
> Set fs = Nothing
> Set ns = Nothing
>
> --
> Roland Hall
> /* This information is distributed in the hope that it will be useful, but
> without any warranty; without even the implied warranty of merchantability
> or fitness for a particular purpose. */
> Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
> WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
> MSDN Library - http://msdn.microsoft.com/library/default.asp
>
>
>

Re: Change a shared folder path? by Al

Al
Mon Feb 21 22:15:55 CST 2005


"Rick Voland" <RickVoland@discussions.microsoft.com> wrote in message
news:8BA53F2B-E768-4910-AD06-AB2B51600835@microsoft.com...
> If I have to delete the share and then recreate it, I need to make sure it
> has the same permissins that it had before it was deleted. Any Ideas on
how
> to preserve the original share permissions?

No, but it should not be an issue if you make the permissions FULL for
EVERYONE, and then actually manage the access using NTFS permissions on the
actual folder and its contents.

/Al

> "Roland Hall" wrote:
>
> > "Rick Voland" wrote in message
> > news:AE23DD09-7BAD-4215-9B61-EDC45B2918AE@microsoft.com...
> > :I have about 300 shared folders that I need to have the path changed
> > because
> > : we the folders are getting moved to another drive. I can list and
create
> > : shares, but cannot figure out how to change the path of an existing
share.
> > I
> > : get an error when I try to change it. Can this be done with VBScript
or
> > is
> > : there another tool I can use?
> >
> > I don't think you can change the path of an existing share. I think if
you
> > want to reuse that share, you have to delete it and then recreate it
setting
> > the new path. If it is possible to just modify the path, I haven't
figured
> > out a way to do it.
> >
> > Dim fs, share, sharePath, ns, computerName, sh
> > ' Written by Roland Hall - http://kiddanger.com/
> > computerName = "myComputer"
> > share = "myShare"
> > sharePath = "c:\mySharePath"
> >
> > wscript.echo "Modifying share path..."
> > Set fs = GetObject("WinNT://" & computerName & "/LanmanServer")
> > for each sh in fs
> > if sh.name = share then
> > wscript.echo "Share:" & sh.name
> > wscript.echo "oldPath: " & sh.path
> > fs.delete "fileshare", share
> > fs.SetInfo
> > end if
> > next
> > set ns = fs.create("fileshare", share)
> > ns.path = sharePath
> > ns.SetInfo
> > wscript.echo "newPath: " & ns.path
> >
> > Set fs = Nothing
> > Set ns = Nothing
> >
> > --
> > Roland Hall
> > /* This information is distributed in the hope that it will be useful,
but
> > without any warranty; without even the implied warranty of
merchantability
> > or fitness for a particular purpose. */
> > Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
> > WSH 5.6 Documentation -
http://msdn.microsoft.com/downloads/list/webdev.asp
> > MSDN Library - http://msdn.microsoft.com/library/default.asp
> >
> >
> >



Re: Change a shared folder path? by Al

Al
Mon Feb 21 22:14:41 CST 2005


"Rick Voland" <RickVoland@discussions.microsoft.com> wrote in message
news:F4A7F005-9550-45BC-B2C8-23A3E51DCD83@microsoft.com...
> The error I get is:
> Modify Share.vbs(14, 5) Active Directory: The specified directory property
> is not supported.

I strongly suspect that the .path property of an already existing share is a
read-only one. That certainly seems to be the case for MMC (manage my
computer), as the share name and path fields are both greyed out.

/Al

> "Brandon McCombs" wrote:
>
> >
> >
> > Rick Voland wrote:
> >
> > > I have about 300 shared folders that I need to have the path changed
because
> > > we the folders are getting moved to another drive. I can list and
create
> > > shares, but cannot figure out how to change the path of an existing
share. I
> > > get an error when I try to change it. Can this be done with VBScript
or is
> > > there another tool I can use?
> > >
> >
> > what error do you get?
> >
> > >
> > > Please help,
> > >
> > > Rick
> > > ==================================
> > > Creating share:
> > >
> > > Set FservObj = GetObject("WinNT://ComputerName/lanmanserver")
> > >
> > > set newshare = FservObj.create("fileshare","test")
> > > newshare.path = "C:\temp"
> > > newshare.setinfo
> > > Set newshare = nothing
> > >
> > > =====================================
> > > Listing Share info:
> > >
> > > Set FS = GetObject("WinNT://stretch2400/LanmanServer/Test1")
> > > Wscript.Echo vbtab & fs.Path
> > > Wscript.Echo vbtab & fs.MaxUserCount
> > > Wscript.Echo vbtab & fs.AdsPath
> > > Wscript.Echo vbtab & fs.Path
> > > Wscript.Echo vbtab & fs.Class
> > > Wscript.Echo vbtab & fs.CurrentUserCount
> > > Wscript.Echo vbtab & fs.description
> > > Wscript.Echo vbtab & fs.GUID
> > > Wscript.Echo vbtab & fs.HostComputer
> > > Wscript.Echo vbtab & fs.Parent
> > > Wscript.Echo vbtab & fs.Schema
> > > ' *** This is where I get the error.
> > > ' FS.Path = "C:\Scripts"
> > > ' FS.SetInfo
> > > ' Wscript.Echo vbtab & fs.Path
> >
> >



Re: Change a shared folder path? by Roland

Roland
Tue Feb 22 00:15:04 CST 2005

"Al Dunbar [MS-MVP]" wrote in message
news:uvis2UJGFHA.2876@TK2MSFTNGP12.phx.gbl...
:
: "Rick Voland" <RickVoland@discussions.microsoft.com> wrote in message
: news:8BA53F2B-E768-4910-AD06-AB2B51600835@microsoft.com...
: > If I have to delete the share and then recreate it, I need to make sure
it
: > has the same permissins that it had before it was deleted. Any Ideas on
: how
: > to preserve the original share permissions?
:
: No, but it should not be an issue if you make the permissions FULL for
: EVERYONE, and then actually manage the access using NTFS permissions on
the
: actual folder and its contents.

That's all I have found on the subject. Also, if you manually set a share
in explorer, you set rights separate than creating, deleting the share.
With 'net share', you just create/delete the share and default is EVERYONE
FULL.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp



Re: Change a shared folder path? by Brandon

Brandon
Tue Feb 22 22:44:59 CST 2005



"Al Dunbar [MS-MVP]" wrote:

> "Rick Voland" <RickVoland@discussions.microsoft.com> wrote in message
> news:F4A7F005-9550-45BC-B2C8-23A3E51DCD83@microsoft.com...
> > The error I get is:
> > Modify Share.vbs(14, 5) Active Directory: The specified directory property
> > is not supported.
>
> I strongly suspect that the .path property of an already existing share is a
> read-only one. That certainly seems to be the case for MMC (manage my
> computer), as the share name and path fields are both greyed out.

what is MMC? the only MMC I know of is Microsoft Management Console


Re: Change a shared folder path? by Brandon

Brandon
Tue Feb 22 22:46:52 CST 2005



Rick Voland wrote:

> I have about 300 shared folders that I need to have the path changed because
> we the folders are getting moved to another drive. I can list and create
> shares, but cannot figure out how to change the path of an existing share. I
> get an error when I try to change it. Can this be done with VBScript or is
> there another tool I can use?

sorry I didn't read your first post closely enough Rick. Using the manual
method, I've never been able to modify the shared path of a network share. I
always have to unshare it, hit apply and then share it again. The directory
permissions stay the same when I do that and only the share permissions need set
again. I'd assume that trying to do it within a script as someone else mentioned
is just not possible.

Brandon



Re: Change a shared folder path? by Michael

Michael
Wed Feb 23 19:25:01 CST 2005

>> I strongly suspect that the .path property of an already existing
>> share is a read-only one. That certainly seems to be the case for
>> MMC (manage my computer), as the share name and path fields are both
>> greyed out.
>
> what is MMC? the only MMC I know of is Microsoft Management Console

Probably referring to the Manage... context menu item for "My Computer", aka
the Computer Management (compmgmt.msc) MMC snap-in...


--
Michael Harris
Microsoft MVP Scripting
http://maps.google.com/maps?q=Sammamish%20WA%20US



Re: Change a shared folder path? by Al

Al
Wed Feb 23 23:10:33 CST 2005


"Michael Harris (MVP)" <mikhar at mvps dot org> wrote in message
news:%234ATZ%23gGFHA.2280@TK2MSFTNGP15.phx.gbl...
> >> I strongly suspect that the .path property of an already existing
> >> share is a read-only one. That certainly seems to be the case for
> >> MMC (manage my computer), as the share name and path fields are both
> >> greyed out.
> >
> > what is MMC? the only MMC I know of is Microsoft Management Console
>
> Probably referring to the Manage... context menu item for "My Computer",
aka
> the Computer Management (compmgmt.msc) MMC snap-in...

Correct. And the only MMC I know of is Microsoft Management Console too.

/Al