Hi There,
I was wondering if anyone can help me with the following problem:
I have written an app to easily create a share on a remote computer utilizing WMI, however I cannot seem to get it working, I end up with a "Provider is not capable of the attempted operation" error. I have full admin access to the remote server so permissions should not be an issue. Any help or suggestions would be greatly appreciated. Below is the code in question:
try { ManagementPath winSharePath = new ManagementPath("Win32_Share"); ManagementScope winShareScope = new ManagementScope(@"\\server01\root\cimv2"); ManagementClass winShareClass = new ManagementClass(winShareScope,winSharePath,null); ManagementObject shareObject = winShareClass.CreateInstance(); shareObject["Path"] = @"E:\Test"; shareObject["Name"] = "TestShare$"; shareObject["Type"] = 0; shareObject["Description"] = "Test Share Description"; PutOptions shareOptions = new PutOptions(); shareOptions.Type = PutType.UpdateOrCreate; shareOptions.Timeout = TimeSpan.MaxValue; shareObject.Put(shareOptions); } catch (Exception err) { MessageBox.Show(err.Message); }
|
Cheers
Ben