locked
WMI call from ASP.NET application on IIS server RRS feed

  • Question

  • I have no idea if this is the correct place to ask this; but here goes.

    After testing local using IIS Express on my Windows 10 dev machine, I have deployed an ASP .NET application to IIS 8.5 on Server 2012 R2.  It is a custom web printing tool running in its own application pool.

    I am using Win32_Printer to get details on the printers.  However it keeps crashing wmiprvse.exe.

    In the WMI-Activity event log I get:

    Id = {...}; ClientMachine = XXXXX; User = IIS APPPOOL\xxxxxx; ClientProcessId = 2856; Component = Unknown; Operation = Start IWbemServices::ExecQuery - root\CIMV2 : SELECT * FROM Win32_Printer WHERE Local=true; ResultCode = 0x800706BE; PossibleCause = Unknown

    If I login to the server (with my admin account) and use powershell to call Get-WmiObject Win32_Printer I get valid data returned.  After that the ASP .NET application works (at least until server restarts).

    Thanks,

    Mark

    • Moved by Bill_Stewart Thursday, January 25, 2018 9:53 PM This is not IIS support forum
    Monday, October 23, 2017 8:03 PM

All replies

  • Post ASP.Net issues here: http://forums.asp.net

    IIS cannot query WMI without setting up special settings on the app pool.  The ASP folks will show you how to do this.  This is a scripting forum. ASP.Net is not a scripting language.


    \_(ツ)_/

    Monday, October 23, 2017 8:11 PM
  • Yep, another thread\forum said this was the place to ask general WMI questions.  So was asking here in case there was any WMI permissions anyone would advice me on.

    Anyway; I changed the app pool to run as "Local Service" account as this has the necessary WMI permissions.  Whereas the virtual account IIS APPPOOL\xxxxxx doesn't.

    Tuesday, October 24, 2017 11:26 AM
  • WMI is a service.  It is not a script.  ASP.Net is a compiled language run under IIS.  Be careful how you run the pool or you can get hacked.


    \_(ツ)_/

    Tuesday, October 24, 2017 11:31 AM