Quick VBscriptWell, today I briefly developed this script (under one minute I think) to grab a serial number from a remote computer using WMI. It's not exactly an elegant script, as it'll throw a nasty error if it can't contact the remote computer, although if you know the computer is most likely on, you should have no problems retrieving the serial # from it. Anyway, without further to do, here it is: strComputer = inputbox("Computer name:") set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") sClass = "win32_bios" sQuery = "select serialnumber from " & sClass set results = objWMI.ExecQuery(sQuery)
for each result in results wscript.echo strComputer & " :: " & result.serialnumber next
¶ 3:29 PM0 comments
Saturday, February 04, 2006
Stunning results with multi-threaded application developmentWow ... I've just spent some time today studying multi-threaded application development, and have been absolutely amazed with the results from the multi-threaded test program I created. What kills me most about this new discovery of mine is how easy it is to spawn additional worker threads to make your application more responsive. Here's a great example of how you could use multi-threading: if your application is accessing data from a remote computer on a slow WAN link, you can tell you app to spawn a new thread for the data access, while your main user interface window can continue on in perfect bliss! This is almost exactly what I'm doing with my current test application when connecting to the WMI service on a remote computer. Additionally, since you can specify a different priority for a new thread, this is perfect for times you're running a particularly hefty (lower-priority) WMI query in the background and don't want to make your app lock up while it's in progress. In my future development of a computer management application, I will be sure to take advantage of this awesome, yet easily-implemented feature.
FYI: Don't forget to leave out the parentheses when you're specifying a delegate method, otherwise it'll think you're trying to call the function and give the the following compile-time error: "Method name expected"
¶ 5:28 PM0 comments
Solutions to problemsWell I've been hacking at a problem that I just figured out. In my code writing, I'm trying to access some information retained in the WMI repository on a computer, and I was having some issues with data conversions. I did some debugging of my own, and I found out that the type being returned from WMI was a uint64, and of course I'm expecting the conversion to be easy. It turns out you can't do an implicit/explicit cast on the value to get a 32-bit integer, which makes sense, and the System.Convert class in the .NET 2.0 Framework doesn't contain a ToUint32 method that takes a uint64 as a parameter (but the .NET 1.1 Framework does). Anyway, I finally figured out that I could call the ToString() method on the property value I was retrieving from WMI (the capacity property in the \\localhost\root\cimv2:Win32_PhysicalMemory class), and then convert the string to a int32. Finally!
¶ 11:30 AM0 comments
Friday, February 03, 2006
Creating a collection classI came across this great article within the MSDN documentation that explains how to create your own collection class in .NET. It explains how to implement the Add() and Remove() methods along with the Item property to allow you to access a particular object in your collection via its index value. While they show the index as being an integer in this article, I am assuming that you can also use a string as an index.
¶ 5:53 PM0 comments
My life of learning various things about technology including network administration, development, and 3D design