Script works with Wscript but not in ASP

M

multisync

I have the following script:

<%
strComputer = "CPU210"
Set objWMIService = GetObject("winmgmts://" & strComputer &
"/root/cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS",,48)
For Each objItem in colItems
serialno = objItem.SerialNumber
Next

%>
<%=serialno%>

If i'm logged onto the computer "CPU210" it will display the serial
number. If I change the strComputer variable to "CPU215" and try to run
this page on CPU210 i get an error. But if i run the page on CPU215
with strComputer = CPU215 it works.

If i put this into a VBScript it works fine, no matter what computer i
run it on and no matter what the strComputer variable is.

So my question is, how do I fix this. All i'm trying to do is get the
LOCAL serial number from a computer in AD. I am not trying to get the
serial number from AD. I want to get the serial number from the actual
machine.
 
J

Jim in Arizona

multisync said:
I have the following script:

<%
strComputer = "CPU210"
Set objWMIService = GetObject("winmgmts://" & strComputer &
"/root/cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS",,48)
For Each objItem in colItems
serialno = objItem.SerialNumber
Next

%>
<%=serialno%>

If i'm logged onto the computer "CPU210" it will display the serial
number. If I change the strComputer variable to "CPU215" and try to run
this page on CPU210 i get an error. But if i run the page on CPU215
with strComputer = CPU215 it works.

If i put this into a VBScript it works fine, no matter what computer i
run it on and no matter what the strComputer variable is.

So my question is, how do I fix this. All i'm trying to do is get the
LOCAL serial number from a computer in AD. I am not trying to get the
serial number from AD. I want to get the serial number from the actual
machine.


You may want to try the classic ASP group:
news://msnews.microsoft.com/microsoft.public.inetserver.asp.general
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top