Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error running WMI script to client machine from ASP.NET

Status
Not open for further replies.

SNosko

Technical User
Jul 3, 2002
73
0
0
US
Hi,

I’m trying to get the Serial Number of the local client from an ASP.NET webpage. When I run the code below I get the following error: Any ideas? SNosko

______

ERROR:

Exception Details: System.Exception: Cannot create ActiveX component.

Source Error:

Line 94: Private Function SerialNum()
Line 95: Dim strComputer = Request.UserHostName
Line 96: Dim objWMIService = GetObject("winmgmts:" _
Line 97: & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Line 98: Dim colBIOS = objWMIService.ExecQuery("Select * from Win32_BIOS")

Source File: \\bhcsql\ Line: 96

Stack Trace:

[Exception: Cannot create ActiveX component.]
Microsoft.VisualBasic.Interaction.GetObject(String PathName, String Class) +62
BHCWOSystem.WebForm1.SerialNum() in \\bhcsql\ BHCWOSystem.WebForm1.btnEnter_Click(Object sender, EventArgs e) in \\bhcsql\ System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292

_________

CODE: (Not all of the code: Only the necessary code)

Imports System
Imports System.Data.OleDb
Imports System.Data.SqlClient
Imports System.management
Imports System.Web
Imports System.Net


Public ReadOnly Property UserHostAddress() As String
Get
Dim instance As HttpRequest
Dim IPAddr As String
IPAddr = instance.UserHostAddress
End Get
End Property

Private Function SerialNum()
Dim strComputer = Request.UserHostName
Dim objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Dim colBIOS = objWMIService.ExecQuery("Select * from Win32_BIOS")
Dim objBIOS
For Each objBIOS In colBIOS
varSerialNum = objBIOS.SerialNumber
Next
Return varSerialNum
End Function

Private Sub btnEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnter.Click
SerialNum()
Me.txtSNum.Text = varSerialNum
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top