Hi all,
I'm writing a GUI-application whixh is in fact the program which
'replaces' the User Manager in our shops.
So, It works almost ... just a last 'problem'.

In fact, when creating a user, I create also the Home-directory and a
share on the folder (all created on the server).
The application runs as well on the server as on the workstations. We
work with Server 2003 / XP.

I can create the home-directory and share when the application runs on
the server.
But when it runs on the WORKSTATIONS, I CAN'T create the SHARE.
An error does always occur !

Does anyone has an idea why it doesn't work ?
I'm looking for a 'script'-solution : I mean, I do not want to use
some 'external' EXE's like RMTSHARE.EXE (if possible).

Here's the code :
For the folder :

On Error GoTo ERROR_HANDLING
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder(as_folder) 'UNC-name like :
'\\S099C01\Home$\test001'

For the share :

On Error GoTo ERROR_HANDLING

Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\" & as_server & "\root\cimv2")
Set objNewShare = objWMIService.Get("Win32_Share")
nReturn = objNewShare.Create(as_directory, as_sharename,
FILE_SHARE, Null, as_comment)

'with 'as_server' is the servername : ex. : 'S0999C01'
' 'as_directory' is the LOCAL path on the server : ex. :
'U:\Home\test001'

If nReturn <> 0 Then
Select Case nReturn
...
End Select
Else
End If

Thanks,
Marc.

Re: Creating share on Home-directory : fails on workstation ... works on server ... by Thorsten

Thorsten
Mon Nov 29 06:10:47 CST 2004

Hi Marc,

Try it using the WinNT provider. Yes it works with 2003... ;o)
Example:

Set oSharePrivider = GetObject("WinNT://" & strDomain & "/" & strServer &
"/LanmanServer")
Set oShare = oShareProvider.Create("FileShare", strShareName) '
oShare.Path = Partition & ":" & DirPath
oShare.MaxUserCount = -1 ' No Limit
oShare.SetInfo


"Schmidtmayer Marc" <marc.schmidtmayer@gb.be> schrieb im Newsbeitrag
news:6ba0254d.0411282338.1ee27b79@posting.google.com...
> Hi all,
> I'm writing a GUI-application whixh is in fact the program which
> 'replaces' the User Manager in our shops.
> So, It works almost ... just a last 'problem'.
>
> In fact, when creating a user, I create also the Home-directory and a
> share on the folder (all created on the server).
> The application runs as well on the server as on the workstations. We
> work with Server 2003 / XP.
>
> I can create the home-directory and share when the application runs on
> the server.
> But when it runs on the WORKSTATIONS, I CAN'T create the SHARE.
> An error does always occur !
>
> Does anyone has an idea why it doesn't work ?
> I'm looking for a 'script'-solution : I mean, I do not want to use
> some 'external' EXE's like RMTSHARE.EXE (if possible).
>
> Here's the code :
> For the folder :
>
> On Error GoTo ERROR_HANDLING
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Set objFolder = objFSO.CreateFolder(as_folder) 'UNC-name like :
> '\\S099C01\Home$\test001'
>
> For the share :
>
> On Error GoTo ERROR_HANDLING
>
> Set objWMIService = GetObject("winmgmts:" &
> "{impersonationLevel=impersonate}!\\" & as_server & "\root\cimv2")
> Set objNewShare = objWMIService.Get("Win32_Share")
> nReturn = objNewShare.Create(as_directory, as_sharename,
> FILE_SHARE, Null, as_comment)
>
> 'with 'as_server' is the servername : ex. : 'S0999C01'
> ' 'as_directory' is the LOCAL path on the server : ex. :
> 'U:\Home\test001'
>
> If nReturn <> 0 Then
> Select Case nReturn
> ...
> End Select
> Else
> End If
>
> Thanks,
> Marc.



Re: Creating share on Home-directory : fails on workstation ... works on server ... by marc

marc
Tue Nov 30 02:09:28 CST 2004

Hi Thorsten,

Thanks for your help.
I'll try it out !

In the mean time, I've found that a particular right was not been set,
namely : "The current user hasn't been granted the "remote connect"
WMI privilege".

I'll do the test with the WinNT-provider ...

Thanks again !
Marc.


"Thorsten Helfer" <thorsten.helfer@it-helfer.de> wrote in message news:<egUZ2xg1EHA.304@TK2MSFTNGP11.phx.gbl>...
> Hi Marc,
>
> Try it using the WinNT provider. Yes it works with 2003... ;o)
> Example:
>
> Set oSharePrivider = GetObject("WinNT://" & strDomain & "/" & strServer &
> "/LanmanServer")
> Set oShare = oShareProvider.Create("FileShare", strShareName) '
> oShare.Path = Partition & ":" & DirPath
> oShare.MaxUserCount = -1 ' No Limit
> oShare.SetInfo
>
>
> "Schmidtmayer Marc" <marc.schmidtmayer@gb.be> schrieb im Newsbeitrag
> news:6ba0254d.0411282338.1ee27b79@posting.google.com...
> > Hi all,
> > I'm writing a GUI-application whixh is in fact the program which
> > 'replaces' the User Manager in our shops.
> > So, It works almost ... just a last 'problem'.
> >
> > In fact, when creating a user, I create also the Home-directory and a
> > share on the folder (all created on the server).
> > The application runs as well on the server as on the workstations. We
> > work with Server 2003 / XP.
> >
> > I can create the home-directory and share when the application runs on
> > the server.
> > But when it runs on the WORKSTATIONS, I CAN'T create the SHARE.
> > An error does always occur !
> >
> > Does anyone has an idea why it doesn't work ?
> > I'm looking for a 'script'-solution : I mean, I do not want to use
> > some 'external' EXE's like RMTSHARE.EXE (if possible).
> >
> > Here's the code :
> > For the folder :
> >
> > On Error GoTo ERROR_HANDLING
> > Set objFSO = CreateObject("Scripting.FileSystemObject")
> > Set objFolder = objFSO.CreateFolder(as_folder) 'UNC-name like :
> > '\\S099C01\Home$\test001'
> >
> > For the share :
> >
> > On Error GoTo ERROR_HANDLING
> >
> > Set objWMIService = GetObject("winmgmts:" &
> > "{impersonationLevel=impersonate}!\\" & as_server & "\root\cimv2")
> > Set objNewShare = objWMIService.Get("Win32_Share")
> > nReturn = objNewShare.Create(as_directory, as_sharename,
> > FILE_SHARE, Null, as_comment)
> >
> > 'with 'as_server' is the servername : ex. : 'S0999C01'
> > ' 'as_directory' is the LOCAL path on the server : ex. :
> > 'U:\Home\test001'
> >
> > If nReturn <> 0 Then
> > Select Case nReturn
> > ...
> > End Select
> > Else
> > End If
> >
> > Thanks,
> > Marc.