473,396 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Creating share folders and setting permission using vb.net

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

Aug 15 '07 #1
0 2086

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: brian.oneil2 | last post by:
Is there a way to install this onto a network file share and allow a team to access it? I would say share a CD from a networked CD drive, but there are multiple CD's that would have to be inserted....
8
by: JR | last post by:
I have a Web server running on Windows XP. On this Web server, I have a Web site configured with its home directory on a network share. In the Web site, there's a virtual folder pointing to a local...
15
by: David Thielen | last post by:
Hi; My ASP.NET app (C# calling J# under .net 2.0) creates a png file in a subdirectory to display as part of the created page. However, the bitmap will not display due to a security violation. ...
3
by: Michel Smit | last post by:
Hello, I have a question. We have a webserver in a domain, DomainA, and a webserver in a DMZ with local users and groups only. I'm trying to copy a file from the DomainA webserver to the DMZ...
2
by: Bill Fallon | last post by:
I have a VS2005 VB.Net windows form application deployed to a share drive. The windows explorer security permissions for this application (.exe) file is set for Everyone with List Folder/Read Data...
17
by: NetworkElf | last post by:
Hi all, I'm writing a service that needs to discover the full directory path for a given locally based share at startup. IOW, I need to have the service running on someserver to take ...
0
by: =?Utf-8?B?U2FsaW0=?= | last post by:
Hi .Net gurus, I have a .Net C# application. I need to set permission for a domain user on given file share. Admin specifies the file share name as \\machine-name\shared Folder and user name...
1
by: =?Utf-8?B?aGVjc2FuMDc=?= | last post by:
Hello I am fairly new to .NET Development. I need to query folders within a network drive and return some metadata related to the directories. For instance, I might have the following path:...
1
by: Mick Walker | last post by:
Hi all, I am wondering is it possible to create a physical Directory such as "C:\Test" using the DirectoryServices namespace. If so, does anyone have any resources on how to do it? I should...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.