Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a folder share in VBScript 1

Status
Not open for further replies.

sayseal75

Programmer
Aug 22, 2001
2
US
How do I create a share on a local folder on an NT Machine using VBScript??? HELP, I'm a newbie!
 
sayseal75,

For Windows NT,

Set Fso = CreateObject("Scripting.FileSystemObject")
Set WshShell = Wscript.CreateObject("Wscript.Shell")

Set fldr = fso.CreateFolder("I:\foldername")
cmdline = "net share " & "YourShareName" & "=" & "I:\foldername"
Return = WshShell.Run(cmdline, 0, TRUE)


For W2K,
set FservObj = GetObject("WinNT://servername/lanmanserver")
set newshare = FservObj.create("fileshare", "YourShareName")
newshare.path = "I:\foldername"
newshare.description = "Description here"
newshare.SetInfo

Cheers,
fengshui1998

 
That works great if you don't need to put quotes around your folder name because there are spaces in the path (ex. "c:\Program Files\MTS"). What is the syntax for this? I have tried all kinds of combinations...
 
Hello, sayseal75.

If the I:\foldername in FengShui1998's script up there, for you, is c:\Program Files\MTC, then you just replace everywhere :

"I:\foldername" [literal, including "s]
by
chr(34) & "c:\Program Files\MTC" & chr(34)
or, more clumsily,
"""" & "c:\Program Files\MTC" & """"

regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top