Windows Vista Forums

Windows 2008 File Share via VBS

  1. #1


    Dave Susemiehl Guest

    Windows 2008 File Share via VBS

    I have a long script for setting up client ou's share folders etc and we are
    moving to Windows 2008. I want to get the VBScript working before tackling
    the task of proting it to PowerShell and I have one peice that's not working
    I was hoping someone would have some insite into it. I need to be able to
    create a share on a Windows 2008 file server (64 Bit)

    Here's the code that works in our Windows 2003 environment (I added the Echo
    for testing). All the variables are defined earlier in the script (FS=0)

    Set objWMIService = GetObject("winmgmts:" &
    "{impersonationLevel=impersonate}!\\" & strServer & "\root\cimv2")
    Set objNewShare = objWMIService.Get("Win32_Share")
    MkShr = objNewShare.Create (strSharePath,strShareName,FS,,strShareDesc)
    wscript.echo MkShr

    The return code is an 8 (unknown error) when I try to run it.

    Any help would be greatly appreciated. and I'm not oppsed to doing
    somethign completely different (except Powershell I don't have the time right
    now to port the entire script to powershell right now).



    Thanks
    Dave S

      My System SpecsSystem Spec

  2. #2


    Richard Mueller [MVP] Guest

    Re: Windows 2008 File Share via VBS

    Dave Susemiehl wrote:

    >I have a long script for setting up client ou's share folders etc and we
    >are
    > moving to Windows 2008. I want to get the VBScript working before
    > tackling
    > the task of proting it to PowerShell and I have one peice that's not
    > working
    > I was hoping someone would have some insite into it. I need to be able to
    > create a share on a Windows 2008 file server (64 Bit)
    >
    > Here's the code that works in our Windows 2003 environment (I added the
    > Echo
    > for testing). All the variables are defined earlier in the script (FS=0)
    >
    > Set objWMIService = GetObject("winmgmts:" &
    > "{impersonationLevel=impersonate}!\\" & strServer & "\root\cimv2")
    > Set objNewShare = objWMIService.Get("Win32_Share")
    > MkShr = objNewShare.Create (strSharePath,strShareName,FS,,strShareDesc)
    > wscript.echo MkShr
    >
    > The return code is an 8 (unknown error) when I try to run it.
    >
    > Any help would be greatly appreciated. and I'm not oppsed to doing
    > somethign completely different (except Powershell I don't have the time
    > right
    > now to port the entire script to powershell right now).
    Does it work if you specify a value for maximum connections? For example:

    MkShr = objNewShare.Create (strSharePath,strShareName,FS,25,strShareDesc)

    I see the documentation says this parameter can be blank. I don't see any
    documentation yet that mentions W2k8. In the past I've used LanmanServer and
    the WinNT provider to create shares. For example:

    strDomain = "MyDomain"
    strComputer = "MyServer"
    strShare = "MyShareName"
    strFileSharePath = "c:\MyFolder"
    strDescription = "Admin Files"
    Set objComputer = GetObject("WinNT://" & strDomain & "/" & strComputer &
    "/LanmanServer")
    Set objShare = objComputer.Create("fileshare", strShare)
    objShare.Path = strFileSharePath
    objShare.Description = strDescription
    objShare.MaxUserCount = -1
    objShare.SetInfo

    --
    Richard Mueller
    MVP Directory Services
    Hilltop Lab - http://www.rlmueller.net
    --



      My System SpecsSystem Spec

  3. #3


    Dave Susemiehl Guest

    Re: Windows 2008 File Share via VBS

    I've since tested this by running it to create the share on one of the 32 bit
    W2K8 servers in the environment. That works just fine. Also the script
    worked in our older W2K3 environment.

    The server I need this created on is a Windows 2008 server with the file
    server role installed.

    I guess the biggest help would some clue on troubleshooting the response 8.

    When I run the script I can see the logon's occur in the security logs but
    no indication of why the script is failing.

    "Richard Mueller [MVP]" wrote:

    > Dave Susemiehl wrote:
    >

    > >I have a long script for setting up client ou's share folders etc and we
    > >are
    > > moving to Windows 2008. I want to get the VBScript working before
    > > tackling
    > > the task of proting it to PowerShell and I have one peice that's not
    > > working
    > > I was hoping someone would have some insite into it. I need to be able to
    > > create a share on a Windows 2008 file server (64 Bit)
    > >
    > > Here's the code that works in our Windows 2003 environment (I added the
    > > Echo
    > > for testing). All the variables are defined earlier in the script (FS=0)
    > >
    > > Set objWMIService = GetObject("winmgmts:" &
    > > "{impersonationLevel=impersonate}!\\" & strServer & "\root\cimv2")
    > > Set objNewShare = objWMIService.Get("Win32_Share")
    > > MkShr = objNewShare.Create (strSharePath,strShareName,FS,,strShareDesc)
    > > wscript.echo MkShr
    > >
    > > The return code is an 8 (unknown error) when I try to run it.
    > >
    > > Any help would be greatly appreciated. and I'm not oppsed to doing
    > > somethign completely different (except Powershell I don't have the time
    > > right
    > > now to port the entire script to powershell right now).
    >
    > Does it work if you specify a value for maximum connections? For example:
    >
    > MkShr = objNewShare.Create (strSharePath,strShareName,FS,25,strShareDesc)
    >
    > I see the documentation says this parameter can be blank. I don't see any
    > documentation yet that mentions W2k8. In the past I've used LanmanServer and
    > the WinNT provider to create shares. For example:
    >
    > strDomain = "MyDomain"
    > strComputer = "MyServer"
    > strShare = "MyShareName"
    > strFileSharePath = "c:\MyFolder"
    > strDescription = "Admin Files"
    > Set objComputer = GetObject("WinNT://" & strDomain & "/" & strComputer &
    > "/LanmanServer")
    > Set objShare = objComputer.Create("fileshare", strShare)
    > objShare.Path = strFileSharePath
    > objShare.Description = strDescription
    > objShare.MaxUserCount = -1
    > objShare.SetInfo
    >
    > --
    > Richard Mueller
    > MVP Directory Services
    > Hilltop Lab - http://www.rlmueller.net
    > --
    >
    >
    >

      My System SpecsSystem Spec

Windows 2008 File Share via VBS

Similar Threads
Thread Thread Starter Forum Replies Last Post
File share cannot be reached on Windows 2008 SBS via VPN labranyi SBS Server 3 19 Jan 2010
Folder share lost after Server reboot - Windows 2003 R2 File Serve Portopalermo Server General 0 17 Aug 2009
Windows Server 2008 file sharing help sapph Server General 0 21 Jul 2009
coping file from a remote file share - FILE IS NO LONG THERE bogus error message Heith Vista networking & sharing 0 18 Oct 2007
File backup from Vista to Windows XP:Share folder password? Athena Vista file management 0 30 Aug 2007