Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General / November 2004



Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Schmidtmayer Marc - 29 Nov 2004 07:33 GMT
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.
Jim Carlock - 30 Nov 2004 04:20 GMT
Run as Administrator?

Signature

Jim Carlock
Post replies to newsgroup.

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.
Schmidtmayer Marc - 30 Nov 2004 07:55 GMT
Found the problem ...
All ok now !  ;-)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.