시스템에 연결되어 네트워크 어댑터를 알리는 장치에 고정 IP 주소를 할당하는 데 문제가 있습니다. 장치에서 EnableStatic을 호출 할 때마다 IP와 서브넷 마스크를 사용하여 "Access Denied"를 의미하는 0x80041003 오류 코드를 반환합니다. 권한 상승없이 Windows에서 IP 주소를 변경할 수 있습니다.WMI Win32_NetworkAdapterConfiguration "EnableStatic"호출이 반환 결과와 함께 실패 함 0x80041003
는나는 IP 주소를 설정하는 데 사용하고 코드는 다음과 같습니다 : 나는 해결책을 찾고 internets 주위에 사냥 한
/// <summary>
/// Set's a new IP Address and subnet mask for the adapter with the given description.
/// </summary>
/// <param name="description">Description string used to ID the adapter.</param>
/// <param name="ip_address">The IP Address.</param>
/// <param name="subnet_mask">The Submask IP Address</param>
public static void SetIP(string description, string ip, string mask)
{
ManagementClass findAdapters =
new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection adapters = findAdapters.GetInstances();
foreach (ManagementObject adapter in adapters)
{
string name = (string)adapter["Description"];
if (name != description)
{
continue;
}
try
{
ManagementBaseObject newIP =
adapter.GetMethodParameters("EnableStatic");
newIP["IPAddress"] = new string[] { ip };
newIP["SubnetMask"] = new string[] { mask };
ManagementBaseObject setIP =
adapter.InvokeMethod("EnableStatic", newIP, null);
UInt32 result = (UInt32)(setIP["returnValue"]);
}
catch (Exception)
{
throw;
}
}
}
. 가장 가능성있는 것으로 보이는 것은 모든 일이 일어나기 전에 CoInitializeSecurity와 같은 일을해야한다는 것입니다. 그러나 이것은 나에게 이상한 것처럼 보인다. WMI 네임 스페이스를 사용하고 있습니다. WMI가 이런 식으로 어떤 식 으로든 종속된다면 네임 스페이스에도 있어야합니다.
내가 여기에 누락 뭔가가있다....
BTW 사용자로 도메인에 Windows 7을 실행하지만 도움이된다면 로컬 관리자입니다!
상당히 옳습니다. 우리는 어제 이것을 처리 할 수있었습니다. 슬프게도이 릴리스의 서비스를 작성할 시간이 없지만 다음 번에 서비스를 작성할 예정입니다. – Robinson