Sign in to follow this  
david_j_kemp

[web] Visual Basic & HTML

Recommended Posts

Hi all, I have written a VB script to detect a users bios settings and want the information to be displayed in tables using html when they open the page. The code is: ----------------------------------------------------------------- On Error Resume Next strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS",,48) For Each objItem in colItems Wscript.Echo "BuildNumber: " & objItem.BuildNumber Wscript.Echo "Caption: " & objItem.Caption Wscript.Echo "Description: " & objItem.Description Wscript.Echo "Manufacturer: " & objItem.Manufacturer Wscript.Echo "Name: " & objItem.Name Wscript.Echo "ReleaseDate: " & objItem.ReleaseDate Wscript.Echo "SMBIOSBIOSVersion: " & objItem.SMBIOSBIOSVersion Wscript.Echo "SMBIOSMajorVersion: " & objItem.SMBIOSMajorVersion Wscript.Echo "SMBIOSMinorVersion: " & objItem.SMBIOSMinorVersion Wscript.Echo "SoftwareElementID: " & objItem.SoftwareElementID Wscript.Echo "TargetOperatingSystem: " & objItem.TargetOperatingSystem Wscript.Echo "Version: " & objItem.Version Next ----------------------------------------------------------------- At the moment this displays the information in a pop-up box and obviously doesnt use html. All I really need to know what to do is put this in with the html code and display it on the webpage instead of using the dialogue box. If someone could help I would really appreciate it. Thanks David

Share this post


Link to post
Share on other sites
If you put
<script language="VBScript">response.write "something"</script>

anywhere in your HTML page, wherever you put it, the text "something" will appear. You can use this to print out the variables.

Share this post


Link to post
Share on other sites
Replace your Wscript.Echo's with response.write's and build a table around it, then embed it in your webpage.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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 Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS",,48)
For Each objItem in colItems
document.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'".

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Thats the idea benryves I tried it and get no error but it still doesnt display any info, just a blank page. Any ideas?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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 colItems
response.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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this