Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to create a network share using vbScript.

Is there a way of doing this other than executing a "net share" command?


Set shell = CreateObject("WScript.Shell")
shell.Run "net share sc1=" & sShare , 1, false
share|improve this question
up vote 2 down vote accepted

Use WMI via vbscript.

Taken from

Creating a Network Share

Creates a shared folder named FinanceShare, setting the maximum number of simultaneous connections to 25, and adding a share description.

Const FILE_SHARE = 0
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objNewShare = objWMIService.Get("Win32_Share")
errReturn = objNewShare.Create _
    ("C:\Finance", "FinanceShare", FILE_SHARE, _
        MAXIMUM_CONNECTIONS, "Public share for the Finance group.")
Wscript.Echo errReturn
share|improve this answer
I found that the folder I was sharing needed a \ on the end to make this work. – seanyboy Nov 3 '10 at 12:14

Try this -

Dim WshNetwork
Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.MapNetworkDrive "E:", "\\Server\Public"

Taken from this MSDN page -

It is how we map network shares in our login scripts.

share|improve this answer
That's mapping a network share - not creating a network share. But thanks. – seanyboy Nov 3 '10 at 9:57
Duh, sorry about that. – Christopher Nov 3 '10 at 15:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.