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:
Ben Taylor3 reputationPosted Dec 30, 2009, 5:38 PM EST
0
Figured it out! I was using the wrong method I should have been using the InvokeMethod of the ManagementClass object. Correct code is below incase it helps anyone else.
ManagementPath winSharePath = new ManagementPath("Win32_Share");
ManagementScope winShareScope = new ManagementScope(@"\\server01\root\cimv2");
ManagementClass winShareClass = new ManagementClass(winShareScope, winSharePath, null);
ManagementBaseObject shareParams = winShareClass.GetMethodParameters("Create");
shareParams["Path"] = @"E:\Test";
shareParams["Name"] = "TestShare$";
shareParams["Type"] = 0;
shareParams["Description"] = "Test Share Description";
ManagementBaseObject winShareResult = winShareClass.InvokeMethod("Create", shareParams, null);
Mayur Vadher55 reputationPosted Oct 6, 2010, 10:08 PM EDT
0
hello, here is my code.
Dim moSearch As Management.ManagementObjectSearcher = New Management.ManagementObjectSearcher("Select * from Win32_POTSModem") '' get serach data Dim oc As Management.ManagementObjectCollection = moSearch.Get() '' list of every modems install in computer For Each m As Management.ManagementObject In oc '' check modem status '' status "OK" means ready to use If m("Status").ToString() = "OK" Then
''' properties list ''' http://msdn.microsoft.com/en-us/library/aa394360%28VS.85%29.aspx If m("Name").ToString & "[" & m("AttachedTo").ToString() & "]" = oldNm Then Dim p As String = m.Item("Name") m.SetPropertyValue("Name", newNm) Dim moo As New Management.ManagementOperationObserver() Dim shareOptions As New Management.PutOptions() shareOptions.Type = Management.PutType.UpdateOrCreate shareOptions.Timeout = TimeSpan.MaxValue m.Put(shareOptions) 'm.SetQualifierValue("Name", newNm) Exit For End If End If Next for above code i got error like "Provider is not capable of the attempted operation", when i call put function.
Lalit MRank #1,186 · 1.5K reputationPosted Dec 28, 2009, 7:42 PM EST
Ben Taylor3 reputationPosted Dec 30, 2009, 5:38 PM EST
ManagementPath winSharePath = new ManagementPath("Win32_Share");
ManagementScope winShareScope = new ManagementScope(@"\\server01\root\cimv2");
ManagementClass winShareClass = new ManagementClass(winShareScope, winSharePath, null);
ManagementBaseObject shareParams = winShareClass.GetMethodParameters("Create");
shareParams["Path"] = @"E:\Test";
shareParams["Name"] = "TestShare$";
shareParams["Type"] = 0;
shareParams["Description"] = "Test Share Description";
ManagementBaseObject winShareResult = winShareClass.InvokeMethod("Create", shareParams, null);
Cheers
Ben
Mayur Vadher55 reputationPosted Oct 6, 2010, 10:08 PM EDT
here is my code.
Dim moSearch As Management.ManagementObjectSearcher = New Management.ManagementObjectSearcher("Select * from Win32_POTSModem")
'' get serach data
Dim oc As Management.ManagementObjectCollection = moSearch.Get()
'' list of every modems install in computer
For Each m As Management.ManagementObject In oc
'' check modem status
'' status "OK" means ready to use
If m("Status").ToString() = "OK" Then
''' properties list
''' http://msdn.microsoft.com/en-us/library/aa394360%28VS.85%29.aspx
If m("Name").ToString & "[" & m("AttachedTo").ToString() & "]" = oldNm Then
Dim p As String = m.Item("Name")
m.SetPropertyValue("Name", newNm)
Dim moo As New Management.ManagementOperationObserver()
Dim shareOptions As New Management.PutOptions()
shareOptions.Type = Management.PutType.UpdateOrCreate
shareOptions.Timeout = TimeSpan.MaxValue
m.Put(shareOptions)
'm.SetQualifierValue("Name", newNm)
Exit For
End If
End If
Next
for above code i got error like "Provider is not capable of the attempted operation", when i call put function.
any solution.