PC Review


Reply
Thread Tools Rate Thread

How to create a share programmatically in Vista?

 
 
t.w.wetzel@googlemail.com
Guest
Posts: n/a
 
      25th Apr 2009
Hi,

I want to create a share on a Vista computer so that everybody has
full access to the share.
How can I do this?

This code only gives everybody the permission to read the share:

using(System.Management.ManagementClass Win32Share = new
ManagementClass("Win32_Share"))
using(System.Management.ManagementBaseObject parameters =
Win32Share.GetMethodParameters("Create"))
{
parameters["Name"] = "ShareName";
parameters["Path"] = "c:\\Temp";
parameters["Type"] = 0;
parameters["Access"] = null;
parameters["Description"] ="Shared programatically from WMI";
parameters["MaximumAllowed"] = 5;

using(System.Management.ManagementBaseObject result =
Win32Share.InvokeMethod("Create", parameters, null))
{
if (((uint)result["ReturnValue"]) == 0)
{
MessageBox.Show("Folder shared");
}
else
{
MessageBox.Show("Folder share failed");
}
}
}

Thank you
Thomas
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create WebPartZones Programmatically tmeynink@gmail.com Microsoft ASP .NET 0 13th Jun 2006 09:33 AM
Create an MDE File Programmatically =?Utf-8?B?ZGFsYmlu?= Microsoft Access VBA Modules 3 26th May 2006 02:07 PM
programmatically create a macro =?Utf-8?B?SmltIFdhcnJlbg==?= Microsoft Excel Programming 2 16th Mar 2005 10:57 PM
connecting programmatically to a linux samba share Tyler Sample Microsoft Dot NET 2 11th Nov 2004 08:10 PM
Programmatically mount W2K AFP share Lorenzo Thurman Microsoft Windows 2000 Macintosh 4 19th Jun 2004 11:04 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:23 PM.