System.Management.ManagementException

前端 未结 3 1184
梦如初夏
梦如初夏 2021-01-05 12:24

I am running following code:

System.Management.ManagementClass wmiNetAdapterConfiguration = new System.Management.ManagementClass(\"Win32_NetworkAdapterConf         


        
3条回答
  •  囚心锁ツ
    2021-01-05 13:14

    The WMI Service was running for me and I was using a Administrator account.

    I got the exact same error and stacktrace when I was running a command using rsconfig.exe, eg

    cd C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\
    
    rsconfig.exe -c -s sqlserver\instance -d dbName -a SQL -u user -p pass
    

    What I was doing wrong was the instance name has its own argument -i and this fixed it:

    rsconfig.exe -c -s sqlserver -i instance -d dbName -a SQL -u user -p pass
    

    To check the expected arguments run:

    rsconfig.exe /?
    

    Update:

    This is actually incorrect, if you look at the expected arguments it states the server name has to include the instance name as well, you can't have quotes and if the instance name contains a $ sign you may need to escape it, see here for more info: https://stackoverflow.com/a/56370766/495455

提交回复
热议问题