System Info

General HouseBot discussion. Any issues that don't fit into any of the other topics belong here.
dlmorgan999
HouseBot Special Member
Posts: 409
Joined: Tue Jul 13, 2004 9:13 am
Location: Tigard, OR

Post by dlmorgan999 »

PT: the code you posted works great on my machine - thanks! Gee -- if we could only get this level of activity and collaboration on the entire HB forum :wink:
PT
Senior Member
Posts: 147
Joined: Wed Apr 13, 2005 12:32 pm
Location: Hampshire.UK

Post by PT »

Dave



It is funny that you said this about the activity as I nearly commented about it yesterday.It does seem a little more active lately. Perhaps sleeping beauty has awoken!?



Ok next question around the same theme.



Does anyone know how you get the info for only one drive? The scripts I have tried give the whole info located within the class.
Regards

PT

If it isn't broke,fix it till it is!
Richard Naninck
HouseBot Guru Extraordinaire
Posts: 1121
Joined: Tue Sep 28, 2004 7:49 am
Location: The Netherlands

Post by Richard Naninck »

That's easy....



If you use the way I did it in the PC Info script it will not even spin up a parked drive. All of the WMI requests will spin up your drive which was unacceptable for me since my data drives park after 30 minutes and I didn't want them to stay alive just for some info.



So for getting info about just one drive, do some filtering. DriveType 2 will filter out all of the harddrives. Then check for the DriveLetter and there you have your "only one drive". I use this specifically for my D-Drive. That drive holds my Meedio TV recordings. I devide the free space on the D-Drive by 1.5 to get the default amount of recording hours left on that drive and I store that in a separate property which is then being displayed on Meedio TV HouseBot Theme Panel.



So take a look at the PC Info code for the example.
Richard Naninck
HouseBot Guru Extraordinaire
Posts: 1121
Joined: Tue Sep 28, 2004 7:49 am
Location: The Netherlands

Post by Richard Naninck »

Below are two examples about the same thing. The first example is the same as PT uses it and the second is much simpler to read. There is no need to open an object and do all kinds of queries.



--------------------------------------------------------------



strComputer = "."

Set WMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colDisks = WMIService.ExecQuery("Select * from Win32_LogicalDisk")

For each Disk in colDisks

If Disk.DriveType = 3 and Disk.DeviceID = "D:" Then

msgbox Disk.DeviceID & " " & FormatNumber((Disk.FreeSpace / (1024 ^ 3)), 1) & _

" " & FormatNumber((Disk.Size / (1024 ^ 3)), 0) & " " & Disk.Status

End If

Next



Set colDisks = Nothing

Set WMIService = Nothing





------------------------------------------------------------------------------------





For Each Disk In GetObject( "winmgmts:").InstancesOf ("CIM_LogicalDisk")

WScript.Echo "Instance:", Disk.Path_.Relpath

Next
PT
Senior Member
Posts: 147
Joined: Wed Apr 13, 2005 12:32 pm
Location: Hampshire.UK

Post by PT »

Richard Thanks for the reply.

It would seem that you have taken offence to my note. I was only posting a way that I knew how to get some info from windows. I agree that your way would appear much simpler for the most part. Although the two scripts you mention display different information.

I would also agree the benefits of not having to query the drive when it is parked .However the script I posted did not touch on the harddrives, only memory,ip address etc.

This method of querying is used across networks so you can query other machines. I have been able to have all my machines display their properties with this script.



My goal when I asked the original question was to enable some of the functionality to be displayed within a remote. Since asking the question I found the WMI method.
Regards

PT

If it isn't broke,fix it till it is!
Richard Naninck
HouseBot Guru Extraordinaire
Posts: 1121
Joined: Tue Sep 28, 2004 7:49 am
Location: The Netherlands

Post by Richard Naninck »

No offence!

I was also only stating more ways of getting the same results. Sorry if it sounded offensive. I will hide behind the fact that English is not my native language :P

The last I would suggest is that I know anything about vbscript. I am also just in the ripping business when it comes to WMI etc.
dlmorgan999
HouseBot Special Member
Posts: 409
Joined: Tue Jul 13, 2004 9:13 am
Location: Tigard, OR

Post by dlmorgan999 »

I made a slight modification to this script that I thought others might be interested in. I wanted to see uptime in days, hours, minutes instead of hours only. To accomplish this I added the following function to the "PC Info.vbs" script (I got the base code for this from a google search):

Code: Select all

Function FormattedTime(TimeInMinutes)

' This function takes a parameter that is assumed to be minutes of uptime.
' It converts this number to a string representing days, hours and minutes.
'
' EDIT HISTORY:
'   25-Jun-2006  Created.  Dave Morgan

    Dim Days
    Dim Hours
    Dim Minutes

    If TimeInMinutes >= 24 * 60 Then
        Days = TimeInMinutes \ (24 * 60)
    End If

    SELECT CASE Days
        CASE 0
        CASE 1
            FormattedTime = FormattedTime & "1 day, "
        CASE ELSE
            FormattedTime = FormattedTime & Days & " days, "
    END SELECT

    TimeInMinutes = TimeInMinutes MOD (24 * 60)

    If TimeInMinutes >= 60 Then
        Hours = TimeInMinutes \ 60
    End If

    SELECT CASE Hours
        CASE 0
        CASE 1
            FormattedTime = FormattedTime & "1 hour, "
        CASE ELSE
            FormattedTime = FormattedTime & Hours & " hours, "
    END SELECT

    Minutes = TimeInMinutes MOD 60

    SELECT CASE Minutes
        CASE 0
            FormattedTime = FormattedTime & "0 minutes"
        CASE 1
            FormattedTime = FormattedTime & "1 minute"
        CASE ELSE
            FormattedTime = FormattedTime & Minutes & " minutes"
    END SELECT
	
End Function
I also changed the uptime portion of the main script to look like this:

Code: Select all

'-------------------------------------------------------
'- UpTime Info -----------------------------------------
'-------------------------------------------------------
For Each OSObject In GetObject ("winmgmts:").InstancesOf ("Win32_OperatingSystem")
	Bootup         = OSObject.LastBootUpTime
	LastBootupTime = PC_DateStringToDate(Bootup)
	SystemUptime   = DateDiff("n", LastBootUpTime, Now)
	Dinfo          = Dinfo & vbLF & vbTAB & "PC: " & vbTAB & "Boot Date: "  & vbTAB & LastBootupTime & _
	                         vbLF & vbTAB 	      & vbTAB & "PC Up Time: " & vbTAB & FormattedTime(SystemUpTime)
Next

HouseBotStartTime   = GetPropertyValue ("PC Info.HouseBot Start Time")
HouseBotUpTime      = DateDiff("n", HouseBotStartTime, Now)
Dinfo               = Dinfo & vbLF & vbTAB & vbTAB & "HouseBot Up Time: " & vbTAB & FormattedTime(HouseBotUpTime)
The two things that changed in the UpTime script are telling DateDiff to convert to minutes instead of hours (important!) and then calling my function to reformat the result.

-- Dave
HB Guy
Member
Posts: 36
Joined: Fri Jun 30, 2006 3:52 pm
Location: Montréal, QC

I'm logged in ... where is the attachment?

Post by HB Guy »

I'm logged in as "HB Guy" yet I cannot see the attachment. Is it posted somewhere else?

PS
Glad to see HouseBot is back under Scott's exclusive stewardship. I tuned out of HouseBot when it became buried under Meedio. I now find it a little troublesome to find scripts, plugins and other user-contributed information because they appear to distributed in Meedio's site and this one. I hope they'll eventually consolidate under one roof.
Last edited by HB Guy on Wed Jul 05, 2006 1:52 pm, edited 1 time in total.
dlmorgan999
HouseBot Special Member
Posts: 409
Joined: Tue Jul 13, 2004 9:13 am
Location: Tigard, OR

Post by dlmorgan999 »

My guess is that it was lost when the forum was moved back here from the Meedio site. I suspect Scott can post it again but if not I have a copy at home (I'm posting this response from work).

-- Dave
martijnj
Member
Posts: 61
Joined: Mon Nov 03, 2003 2:50 pm
Location: NL

Post by martijnj »

ScottBot wrote:FYI: Also, it creates a startuP Task now. Notice the upper case P. In HouseBot you can have multiple startup tasks by using different case combinations of the name STARTUP.

idea: maybe for the wishlist. Make a Group in Housebot called startup and let all tasks in that group me started at startup. This Solves: startup, Startup, STartup,.....,STARTUP.
HB Guy
Member
Posts: 36
Joined: Fri Jun 30, 2006 3:52 pm
Location: Montréal, QC

Post by HB Guy »

Thanks for the reply.

If anyone has a copy of the script file discussed in this thread I'd appreciate it if you could post it here. Thank you.
ScottBot
Site Admin
Posts: 2790
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Post by ScottBot »

I've corrected the old post and added the attachment. Note that this is the original script without any of the suggested improvements.
Scott
HB Guy
Member
Posts: 36
Joined: Fri Jun 30, 2006 3:52 pm
Location: Montréal, QC

Post by HB Guy »

Scott:

Thank you! I look forward to trying it out and learning more about how to extend HouseBot's functionality.

FYI
I'm 5 days into my evaluation period and I'm extremely impressed with your creation. HouseBot's architecture is clean and extensible; it demonstrates 'clarity of thought'. Kudos to you!
HB Guy
Member
Posts: 36
Joined: Fri Jun 30, 2006 3:52 pm
Location: Montréal, QC

Unable to process dropped file with extension XML

Post by HB Guy »

The zip file, posted in this thread, contains a VB Script file and a Configuration Export file in XML format. I tried dragging and dropping the XML file onto Housebot (V2.32 evaluation) and it resulted in the following error message:

Unable to process dropped file with extension [.xml]. This is an unknown extension type.

I tried "File | Import Configuration" but the file dialog box is only interested in opening files with the extension HBX.

What am I doing wrong?
dlmorgan999
HouseBot Special Member
Posts: 409
Joined: Tue Jul 13, 2004 9:13 am
Location: Tigard, OR

Post by dlmorgan999 »

Rename the ZIP file to PC_Info.hbx and put it in the Export directory. Then stop and restart HouseBot and it should get imported.

By the way, there was an error in the enhancement code I posted a while back. I've fixed it but I need to post updated code. I'll try to do it tonight but I just wanted to warn you now (the problem is that the uptime is not accurately reported for uptimes over one day).

-- Dave
Post Reply