Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / August 2007

Tip: Looking for answers? Try searching our database.

Having trouble creating shared and setting permission using vb.net

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Liam Mac - 15 Aug 2007 15:34 GMT
Hi Folks,

I have embeded WMI scripting within a Visual Basic application to create
remote shares and set permissions, I'm now moving to vb.net environment and
having trouble getting my scripting to work, I have search the net for vb.net
code to create shared folders and set permsission but no joy, if anyone can
help or recommend good web sites on this or is there anyway I can get my
exisiting code to work in vb.net please see code below that works.

Thanks,
Liam

Private Function Create_Share_and_Set_Permissions(strGCN As String,
strServerName As String, strShortCourseCode As String, strDriveLetter As
String)

Set WshShell = CreateObject("Wscript.Shell")
Set WshNetwork = CreateObject("WScript.Network")
Set objFS = CreateObject("Scripting.FileSystemObject")

strFullPath = strDriveLetter & ":\" & strShortCourseCode & "\" & strGCN
strMapName = strServerName & "\" & strGCN & "$"

Me.txtStatus.Value = "Creating Student X Drive"
Me.txtAlert.Value = "Path for X Drive:" & strFullPath

' creating the folder on a remote machine

Set objWMIService = GetObject _
   ("winmgmts:\\" & strServerName & "\root\cimv2:Win32_Process")
errReturn = objWMIService.Create _
   ("cmd.exe /cmd " & strFullPath & "", Null, Null, intProcessID)

subDelay (5)
Me.txtStatus.Value = "Setting Share Permissions on Student X Drive"
Me.txtAlert.Value = ""

' setting the sharing of a folder

Const FILE_SHARE = 0
Const MAXIMUM_CONNECTIONS = 25

Set objWMIService = GetObject _
   ("winmgmts:\\" & strServerName & "\root\cimv2")

Set objNewShare = objWMIService.Get("Win32_Share")

strShareName = strGCN & "$"
errReturn = objNewShare.Create("" & strFullPath & "", "" & strShareName &
"", FILE_SHARE, MAXIMUM_CONNECTIONS, "X Drive")

subDelay (3)
       
       'strUser = "l00069029"
       DisconnectDrive
       MapDrive
       USER_ROOT_UNC = "T:\"

Call WshShell.Run("cacls " & USER_ROOT_UNC & " /e /g CS SysAdmin:F",
HIDE_WINDOW, WAIT_ON_RETURN)
Call WshShell.Run("cacls " & USER_ROOT_UNC & " /e /g " & strUser & ":C",
HIDE_WINDOW, WAIT_ON_RETURN)

Set WshShell = Nothing
Set fso = Nothing
Set WshNetwork = Nothing
pvdg42 - 15 Aug 2007 20:02 GMT
> Hi Folks,
>
[quoted text clipped - 65 lines]
> Set fso = Nothing
> Set WshNetwork = Nothing

I'd suggest the VB.NET group for this question, rather than this academic
group:

microsoft.public.dotnet.languages.vb

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
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



©2008 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.