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

  • Thread starter Thread starter Schmidtmayer Marc
  • Start date Start date
S

Schmidtmayer Marc

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top