473,769 Members | 7,756 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_an d_Set_Permissio ns(strGCN As String,
strServerName As String, strShortCourseC ode As String, strDriveLetter As
String)
Set WshShell = CreateObject("W script.Shell")
Set WshNetwork = CreateObject("W Script.Network" )
Set objFS = CreateObject("S cripting.FileSy stemObject")
strFullPath = strDriveLetter & ":\" & strShortCourseC ode & "\" & strGCN
strMapName = strServerName & "\" & strGCN & "$"
Me.txtStatus.Va lue = "Creating Student X Drive"
Me.txtAlert.Val ue = "Path for X Drive:" & strFullPath

' creating the folder on a remote machine
Set objWMIService = GetObject _
("winmgmts:\ \" & strServerName & "\root\cimv2:Wi n32_Process")
errReturn = objWMIService.C reate _
("cmd.exe /cmd " & strFullPath & "", Null, Null, intProcessID)

subDelay (5)
Me.txtStatus.Va lue = "Setting Share Permissions on Student X Drive"
Me.txtAlert.Val ue = ""
' setting the sharing of a folder

Const FILE_SHARE = 0
Const MAXIMUM_CONNECT IONS = 25
Set objWMIService = GetObject _
("winmgmts:\ \" & strServerName & "\root\cimv 2")

Set objNewShare = objWMIService.G et("Win32_Share ")

strShareName = strGCN & "$"
errReturn = objNewShare.Cre ate("" & strFullPath & "", "" & strShareName &
"", FILE_SHARE, MAXIMUM_CONNECT IONS, "X Drive")

subDelay (3)

'strUser = "l00069029"
DisconnectDrive
MapDrive
USER_ROOT_UNC = "T:\"

Call WshShell.Run("c acls " & USER_ROOT_UNC & " /e /g CS SysAdmin:F",
HIDE_WINDOW, WAIT_ON_RETURN)
Call WshShell.Run("c acls " & 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 2128

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

Similar topics

1
6571
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. TIA, Brian
8
2492
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 folder on the Web server containing an ASP.NET application. I get a "Failed to start monitoring changes" when I try to run the application. If I try to debug, I get a message "unable to start debugging on the Web server". I put an...
15
2836
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. Everything is the default settings I believe. IIS is running under Local System. In IIS the DefaultAppPool is running under Network Service. Annonymous access uses the account IUSR_JASMINE (machine name is Jasmine).
3
5710
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 webserver. Het firewall is configured to allow traffic via NetBIOS by ip-address. File copy takes place in a .NET assembly. Problem is described as follows: when copying I get an error 'access denied'
2
10695
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 not allowed. This is done so that users cannot take away a copy of the .exe file. When I execute the ..exe from the client computer I get .Net Framework Initialization Error, Unable to find a version of the runtime to run this application. The...
17
1852
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 \\someserver\someshare and give me c:\somedir\somedir\shareddir. I'm not quite sure where to start reading about how to do this. Could someone give me a push in the right direction, please?
0
1235
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 domain\user I need to assign domain\user full control on \\machine-name\shared Folder. Is there a simple way to do this in .Net 2.0 C#? Using DirectoryInfo.SetAccessControl is setting permission on the directory but not on the share.
1
1713
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: \\MyServer\Tech I would want to get the size and name of all the folders inside this folder. I tried using a simple DirectoryInfo object, but I am getting AccessDeniedException. I know there has to be a better way of doing this using Impersonation....
1
1317
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 also mention, I am required to create the physical directory on any machine within the current AD domain. Kind Regards
0
9414
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10197
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10032
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9977
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8860
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7391
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6661
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3947
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2810
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.