Inventory in ASP.

J

jaydeep.kubavat

Hi,


I m new to ASP. I have written a script to take inventory of PCs on my
network in an excel spreadsheet. I want it to be available whenever
wherever needed by my managers and other accounts/purchase people. Is
there any way possible that I can put it on my intranet website using
ASP...????


Thanx in advance....


Jaydeep.


Script Code goes here.
'--------------------------------------------------------------------------­-------------------------------

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
x = 1
For i = 1 To 15
objExcel.Cells(x, i).Font.Bold = True
Next
objExcel.Cells(1, 1).Value = "Machine Name"
objExcel.Cells(1, 2).Value = "# of Procs"
objExcel.Cells(1, 3).Value = "Proc Type"
objExcel.Cells(1, 4).Value = "Max Clock Speed"
objExcel.Cells(1, 5).Value = "Tot Phy Mem"
objExcel.Cells(1, 6).Value = "Free Phy Mem"
objExcel.Cells(1, 7).Value = "Tot Virtual Mem"
objExcel.Cells(1, 8).Value = "Free Virtual Mem"
objExcel.Cells(1, 9).Value = "Tot Visible Mem"
objExcel.Cells(1, 10).Value = "Manufacturer"
objExcel.Cells(1, 11).Value = "Model"
objExcel.Cells(1, 12).Value = "OS Serial Number"
objExcel.Cells(1, 13).Value = "Machine Serial Number"
objExcel.Cells(1, 14).Value = "Free Space"
objExcel.Cells(1, 15).Value = "File System"
objExcel.Cells(1, 16).Value = "Device ID"
''''''''''''''''''
x = 2
strComputers = InputBox _
("What computer would you like info on?", _
"Inventory.", strLocalComputer)
On Error Resume Next
Set objNetwork = CreateObject("Wscript.Network")
strLocalComputer = objNetwork.ComputerName
If strComputers = "" Then
WScript.Quit
End If
'''''''
arrComputers = Split(strComputers, " ")
For Each strComputer In arrComputers


objExcel.Cells(x, 1).Value = strComputer
x = x + 1
y = x - 1
''''''''''''''
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\CIMV2")
Set colCSes = objWMIService.ExecQuery("SELECT * FROM
Win32_ComputerSystem")
For Each objCS In colCSes
objExcel.Cells(y, 2).Value = objCS.NumberOfProcessors
Next
Set colProcessors = objWMIService.ExecQuery("Select * from
Win32_Processor")
For Each objProcessor In colProcessors
objExcel.Cells(y, 3).Value = objProcessor.Name
objExcel.Cells(y, 4).Value = objProcessor.MaxClockSpeed
Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\CIMV2")
Set colCSItems = objWMIService.ExecQuery("SELECT * FROM
Win32_ComputerSystem")
For Each objCSItem In colCSItems
objExcel.Cells(y, 5).Value = objCSItem.TotalPhysicalMemory
Next
Set colOSItems = objWMIService.ExecQuery("SELECT * FROM
Win32_OperatingSystem")
For Each objOSItem In colOSItems
objExcel.Cells(y, 6).Value = objOSItem.FreePhysicalMemory
objExcel.Cells(y, 7).Value = objOSItem.TotalVirtualMemorySize
objExcel.Cells(y, 8).Value = objOSItem.FreeVirtualMemory
objExcel.Cells(y, 9).Value = objOSItem.TotalVisibleMemorySize
Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM
Win32_ComputerSystem")
For Each objItem In colItems
objExcel.Cells(y, 10).Value = objItem.Manufacturer
objExcel.Cells(y, 11).Value = objItem.Model
Next
Set colOperatingSystems = objWMIService.ExecQuery("Select * from
Win32_OperatingSystem")
For Each objOperatingSystem In colOperatingSystems
objExcel.Cells(y, 12).Value = objOperatingSystem.SerialNumber
Next
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_BIOS")
For Each objItem In colItems
objExcel.Cells(y, 13).Value = objItem.SerialNumber
Next


Const CONVERSION_FACTOR = 1048576
Set colItems = objWMIService.InstancesOf("SELECT * FROM
Win32_LogicalDisk")
For Each objItem In colItems
FreeMegaBytes = objItem.FreeSpace / CONVERSION_FACTOR
objExcel.Cells(y, 14).Value = objItem.FreeMegaBytes
objExcel.Cells(y, 15).Value = objItem.FileSystem
objExcel.Cells(y, 16).Value = objItem.DeviceID
Next
 
G

Guest

You can write excel content to Response to show excel file on broswer:

Response.ContentType = "application/vnd.ms-excel";
Response.Buffer = true;
Response.AddHeader("Content-Disposition", "inline;filename=" + ExcelFileName);
Response.WriteFile(ExcelFilePath + ExcelFileName);
Response.End();

HTH

Elton Wang
 

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