Scripts Thread, Script to share multiple folders in Coding and Web Development; Hey all, I'm in need of a script that I can use to share alot of folders all in one ...
20th August 2008, 05:29 PM #1
Script to share multiple folders
Hey all, I'm in need of a script that I can use to share alot of folders all in one directory. I have the following for example:
net share <sharename>=<path> /CACHE:no /GRANT:domain\user,READ|CHANGE|FULL
but obviously this requires me to type in each folder name, anyone have a script for automating this? Any help appreciated.
IDG Tech News
20th August 2008, 05:32 PM #2
20th August 2008, 05:43 PM #3
how good are you with VBS?
enumerate all subfolders in a folder:
Scripting Files and Folders using VBScript
use a for each loop that runs a command for each returned folder name
How to: Execute a file/program in VBScript - CRM Developer
Haven't tested it but it should be a good start if it does not work straight away.
folderpath = "C\folder"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(folderpath)
Set colSubfolders = objFolder.Subfolders
For Each objSubfolder in colSubfolders
Run "net share " & objSubfolder.Name & "=" & folderpath & "\" & objSubfolder.Name & " /CACHE:no /GRANT:domain\user,READ|CHANGE|FULL"
Sub Run(ByVal sFile)
Set shell = CreateObject("WScript.Shell")
shell.Run Chr(34) & sFile & Chr(34), 1, false
Set shell = Nothing
Last edited by SYNACK; 20th August 2008 at 05:53 PM.
20th August 2008, 05:48 PM #4
Other way to do this if you're not very confident of your scripting it to use a spread. Use the CONCATENATE function to combine the variables with the rest of the code.
20th August 2008, 06:26 PM #5
Why don't you just share the root of all these folders? With the correct permissions, people would only be able to get into what they should be able to anyway.
If mapping drives off these shares, it is possible to map a subdirectory of a share as a drive letter too.
20th August 2008, 09:01 PM #6
i use this:
FOR /D %%G IN (*.*) DO NET SHARE "%%G=%CD%\%%G" /GRANT:Everyone,FULL /CACHE:None
yours might look like this:
FOR /D %%G IN (*.*) DO net share <sharename>=<path> /CACHE:no /GRANT:domain\user,READ|CHANGE|FULL
run this bat file from the folder containing folders to be shared.
or *.* probably will not work
2 Thanks to box_l:
originofsymmetry (22nd August 2008), simpsonj (16th September 2010)
21st August 2008, 11:54 AM #7
Thanks for these scripts guys, will try them out when I get home tonight
22nd August 2008, 09:35 AM #8
Thanks for that BoX, worked a treat
Originally Posted by box_l
26th August 2008, 12:11 AM #9
Thanks to box_l from:
simpsonj (16th September 2010)
By tosca925 in forum Scripts
Last Post: 26th October 2012, 03:15 PM
By Pumaedition in forum Scripts
Last Post: 22nd April 2008, 11:08 PM
By timbo343 in forum Scripts
Last Post: 19th September 2007, 11:46 PM
By markesmith in forum Scripts
Last Post: 26th April 2007, 04:03 PM
By projector1 in forum Windows
Last Post: 1st February 2007, 09:42 AM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)