[web] Visual Basic & HTML

Started by
18 comments, last by Kylotan 19 years, 6 months ago
Basically I want a webpage which people can log onto and it will use the script to display the relavent info to them on the page. I guess this will be server side as it will be running on the server and just displaying the info to the user (client), although im not sure. After managing to do this I will eventually get round to using the data which is displayed to generate more data from a database maybe, but that doesnt matter for now. If you can help me with just getting a webpage to run the script and display the data to the user I would be greatful.

Thanks again.

David
Advertisement
I have no idea what you're trying to do; this is the code I tried to use:
<html><head><meta name="GENERATOR" content="Microsoft FrontPage 5.0"><meta name="ProgId" content="FrontPage.Editor.Document"><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><title>New Page 1</title></head><body><script language="vbs">On Error Resume NextstrComputer = "."Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS",,48)For Each objItem in colItemsdocument.write "BuildNumber: " & objItem.BuildNumber & "<br />"document.write "Caption: " & objItem.Caption & "<br />"document.write "Description: " & objItem.Description & "<br />"document.write "Manufacturer: " & objItem.Manufacturer & "<br />"document.write "Name: " & objItem.Name & "<br />"document.write "ReleaseDate: " & objItem.ReleaseDate & "<br />"document.write "SMBIOSBIOSVersion: " & objItem.SMBIOSBIOSVersion & "<br />"document.write "SMBIOSMajorVersion: " & objItem.SMBIOSMajorVersion & "<br />"document.write "SMBIOSMinorVersion: " & objItem.SMBIOSMinorVersion & "<br />"document.write "SoftwareElementID: " & objItem.SoftwareElementID & "<br />"document.write "TargetOperatingSystem: " & objItem.TargetOperatingSystem & "<br />"document.write "Version: " & objItem.Version & "<br />"Next</script></body></html>

I've added line breaks (<br />) after each line; however I get the error "ActiveX Control couldn't create object 'GetObject'".

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

Creating a WMI Script says to use:

  Set Locator = CreateObject("WbemScripting.SWbemLocator")  Set Service = Locator.ConnectServer(".", "root\cimv2" )


I've never done WMI scripting before, but MSDN is the first place I'd look.
Thats the idea benryves I tried it and get no error but it still doesnt display any info, just a blank page. Any ideas?
Hi again,

Yes that is right but it just comes up with a blank page. There is nothing wrong with the WMI script evolutional as it worked when just doing it a vb without the html, it just doesnt print the info to the screen now.

Thanks for the help so far if anyone can help finish it off that would be great.

David
Being that WMI is ok and you're using Server side scripting, you can adapt Ben's script to use ASP, instead of client-side VBS, so this should work:

<html><head><meta name="GENERATOR" content="Microsoft FrontPage 5.0"><meta name="ProgId" content="FrontPage.Editor.Document"><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><title>New Page 1</title></head><body><%On Error Resume Next  Set Locator = CreateObject("WbemScripting.SWbemLocator")  Set objWMIService = Locator.ConnectServer(".", "root\cimv2" )Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS",,48)For Each objItem in colItemsresponse.write "BuildNumber: " & objItem.BuildNumber & "<br />"response.write "Caption: " & objItem.Caption & "<br />"response.write "Description: " & objItem.Description & "<br />"response.write "Manufacturer: " & objItem.Manufacturer & "<br />"response.write "Name: " & objItem.Name & "<br />"response.write "ReleaseDate: " & objItem.ReleaseDate & "<br />"response.write "SMBIOSBIOSVersion: " & objItem.SMBIOSBIOSVersion & "<br />"response.write "SMBIOSMajorVersion: " & objItem.SMBIOSMajorVersion & "<br />"response.write "SMBIOSMinorVersion: " & objItem.SMBIOSMinorVersion & "<br />"response.write "SoftwareElementID: " & objItem.SoftwareElementID & "<br />"response.write "TargetOperatingSystem: " & objItem.TargetOperatingSystem & "<br />"response.write "Version: " & objItem.Version & "<br />"Next%></body></html>


Again, I have no means of testing this otherwise I'd be able to help you further.
Quote:Original post by evolutional
Being that WMI is ok and you're using Server side scripting, you can adapt Ben's script to use ASP, instead of client-side VBS, so this should work:

*** Source Snippet Removed ***

Again, I have no means of testing this otherwise I'd be able to help you further.


Or if you want to keep the html a little cleaner, use the above example but with <%MyFunctionName%> in the asp page, with the function def in your vb code behind file.

Public Sub MyFunctionName
'Do stuff
'Build a string based on results of stuff
Response.Write(mystring)
end sub

I use this type of method all the time.
oh hai
Quote:Original post by david_j_kemp
Hi again,

Yes that is right but it just comes up with a blank page. There is nothing wrong with the WMI script evolutional as it worked when just doing it a vb without the html, it just doesnt print the info to the screen now.

Thanks for the help so far if anyone can help finish it off that would be great.

David


The reason you get a blank page is quite straightforwards; you've got some error trapping.
In other words; no error dialogs; it just skips your code and so won't draw anything.

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

david_j_kemp, probably a little clarification is needed. Do you want the person who goes to the site's bios details or the webserver's bios details?
Yeah, no point this being server side if you want the end-user's data. Get rid of that 'On Error Resume Next' in benyrves' code or add a line to print out Err.Description after it and maybe you'll get some useful diagnostics from it.

This topic is closed to new replies.

Advertisement