• 0

VB.NET WSUS Final Question


Question

I can do things like this.. Console.WriteLine(computer.Model)

But, when I try computer.OSInfo - it gives me an error. It says OSInfo cannot be used in a string.

Anybody got any ideas how I can display it?

Thanks! :)

OSInfo : http://msdn.microsoft.com/library/default....rget_osinfo.asp

Link to comment
https://www.neowin.net/forum/topic/422389-vbnet-wsus-final-question/
Share on other sites

17 answers to this question

Recommended Posts

  • 0
  coolant said:

I can do things like this.. Console.WriteLine(computer.Model)

But, when I try computer.OSInfo - it gives me an error. It says OSInfo cannot be used in a string.

Anybody got any ideas how I can display it?

Thanks! :)

OSInfo : http://msdn.microsoft.com/library/default....rget_osinfo.asp

Ok, since I dont have that DLL on my system Im going to make a blanket "duh" statment on the off chance you MIGHT have forgotten this or just didnt know. Almost all .NET objects have a ".ToString" value. Check it out with OSInfo.ToString. If you have, or it doesnt have it also try "Cstr(OSInfo)" (without the quotes of course)

  • 0

Here is the full code (I am learning VB.NET).

'This sends the database the names of the computers and groups that they are in.
Imports Microsoft.UpdateServices.Administration
Imports System.Data
Imports System.Data.Odbc

Module NameGroupsToDatabase

	Sub Main()

		Dim Server As IUpdateServer
		Dim AdminProxy As AdminProxy
		Dim Computers As ComputerTargetCollection
		Dim InstallStatus As UpdateInstallationInfoCollection

		'connect to MySQL
		Dim MyConString As String = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=*****; DATABASE=*******; UID=****; PASSWORD=******; OPTION=3;"
		Dim MyConnection As New OdbcConnection(MyConString)
		MyConnection.Open()

		'drop computerinfo table
		Dim MyCommand As New OdbcCommand
		MyCommand.Connection = MyConnection
		MyCommand.CommandText = "DROP TABLE IF EXISTS computerinfo"
		MyCommand.ExecuteNonQuery()
		MyCommand.CommandText = "DROP TABLE IF EXISTS computerstatus"
		MyCommand.ExecuteNonQuery()

		'create computerinfo table
		MyCommand.CommandText = "CREATE TABLE computerinfo(id varchar(36), groupname varchar(100), compname varchar(100))"
		MyCommand.ExecuteNonQuery()

		'create computerstatusinfo table
		MyCommand.CommandText = "CREATE TABLE computerstatus(id varchar(36), make varchar(100), model varchar(120), proc varchar(120), bios varchar(120))"
		MyCommand.ExecuteNonQuery()

		Console.WriteLine("Obtaining status...")

		'connect to the local server
		AdminProxy = New AdminProxy
		Server = AdminProxy.GetUpdateServer

		'get a collection of the computers on this server
		Computers = Server.GetComputerTargets()

		'loop through the computer collection 
		For Each computer As IComputerTarget In Computers

			'insert into database
			MyCommand.CommandText = "INSERT INTO computerinfo VALUES('" & computer.Id & "', '" & computer.RequestedTargetGroupName & "', '" & computer.FullDomainName & "')"
			MyCommand.ExecuteNonQuery()

			MyCommand.CommandText = "INSERT INTO computerstatus VALUES('" & computer.Id & "', '" & computer.Make & "', '" & computer.Model & "', '" & computer.ProcessorArchitecture & "', '" & computer.OSInfo & "')"
			MyCommand.ExecuteNonQuery()

			Console.WriteLine(computer.FullDomainName & " sent to the database")
			'stupid Next command
		Next
		End
	End Sub

End Module

When I move my mouse over computer.OSInfo - it says that & is not designed for that kind of string.

  • 0

I believe it is becuase OSInfo is an object, not just a version number. My guess is that if you let intellisense pick up with "OSInfo." you would get a list of information. A quick peek on Google brought me to the MSDN site that proved my point. Sorry I dont have the DLL installed to give you specifics.

  • 0

Intellisense is, or at least SHOULD be on by default. By pressing the period ( . ) after an object intellisense will give you a list of functions and properties. See attached image. I created an integer (i), then assigned it a value (3) and then went to print it i. and got this:

Intellisence.jpg

  • 0

For computer.OSInfo it says

"Public Overridale ReadOnly Property OSInfo() As Microsoft.UpdateServices.Administration.OSInfo"

while computer.Model says

"Public Overridale ReadOnly Property Model() As String"

How can I display computer.OSInfo? A loop of some sort?

  • 0

Ok, let's try it this way, your code looks like this:

>> MyCommand.CommandText = "INSERT INTO computerstatus VALUES('" & computer.Id & "', '" & computer.Make & "', '" & computer.Model & "', '" & computer.ProcessorArchitecture & "', '" & computer.OSInfo & "')"

>>

Pull out

"computer.OSInfo"

and place it on it's own line of code

and then after "OsInfo" place a "." so it says:

"computer.OSInfo."

When you place the period after OSInfo do you get a list like the image in my prior post?

If this is still an issue can you give us a small screen shot (damn I wish i had the DLL, but im not muckin up my comp for your code.... deal with it :)

  • 0
  jameswjrose said:

Glad you got it. And yea, a newbie book would be good. I always recommend the "Dummies" books, it shoulds like Im being rude to sugest it, but actually those books are good primers.

Best of luck

Definately. Coming from a PHP person to VB.NET - It can be tricky. OOP is harder then I thought :x

  • 0
  jameswjrose said:

Yes OO is harder than you, or anyone thought, but it does get better. The moment you REALLY get that everything (almost) is an object and what that means will be a cool moment.

Or atleast know what my posibilites are! Now I'm having fun!

Now if I could figure out how to grab the size of a harddrive through WSUS ;)

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • I contacted 0patch and I'm trying to work with it, this is new to me, but I'll figure it before EOL and then get a 5 year patches for € 125. My acer laptop is 6 years old but still going strong, I can maintain it myself; with the help of IFixit, Acer Aspire 7 fully loaded
    • Since win 95 I never used system sound; only the first time to check if the sound card works; after that no annoying click sounds and whistles on every key stroke or every notification. That's why I have my taskbar on top, you'll notice the notification center way sooner at the top right than at the bottom right.
    • 6000MT/s is the sweet spot for DDR5, so then you would be thinking about cache latency, and again CL30 (or lower) is great but don't take my word for it here is a guide I used on my own system with 64GB Kingston Fury CL36 6000 now running at CL30 https://www.patreon.com/posts/low-effort-rank-77403831
    • Here is a list of Samsung Galaxy watches that won't be supported after September 2025 by Sayan Sen Samsung Gear S3 Samsung has confirmed that support for its Tizen-powered smartwatches will officially end in September 2025. The decision marks the final phase of a gradual wind-down process that began last year and reflects the company’s strategic shift toward its Wear OS–powered devices from its own in-house Tizen. If you recall, the South Korean giant began moving away from it back in 2021. The phase-out started on September 30, 2024, when the Galaxy Store stopped offering paid content for Tizen devices. This was followed by another key deadline on May 31, 2025, when new downloads of free Tizen content were disabled. Finally, by the end of September 2025 later this year, users will no longer be able to re-download any previously purchased content via the Galaxy Store. At the time, Samsung had shared the following timeline in an official "Tizen Watch Service Termination Schedule" notice as it wrote: While Samsung has not specified the list of affected wearable devices that will no longer receive Tizen support after September 2025, the following products are likely to be getting the axe: Galaxy Gear Series Samsung Galaxy Gear (Original model) Samsung Galaxy Gear 2 Samsung Galaxy Gear S2 Samsung Gear S3 Classic Samsung Gear S3 Frontier Galaxy Watch Series (Tizen-based) Samsung Galaxy Watch (First Generation / Galaxy Watch 1) Samsung Galaxy Watch Active Samsung Galaxy Watch Active2 Samsung Galaxy Watch 3 Thus, devices launched after the Galaxy Watch3, including the Galaxy Watch4 series and subsequent models, are built on Wear OS and remain unaffected by this transition. On the flip side, Samsung is not planning to switch to Google TV for its TVs, as these still come preloaded with its own Tizen OS, and even offer seven years of support.
    • If I'm not mistaken, doesn't almost al servers run apache, wich is linux
  • Recent Achievements

    • One Month Later
      jezzzy earned a badge
      One Month Later
    • First Post
      CSpera earned a badge
      First Post
    • One Month Later
      MIR JOHNNY BLAZE earned a badge
      One Month Later
    • Apprentice
      Wireless wookie went up a rank
      Apprentice
    • Week One Done
      bukro earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      628
    2. 2
      ATLien_0
      282
    3. 3
      +FloatingFatMan
      180
    4. 4
      Michael Scrip
      150
    5. 5
      Steven P.
      119
  • Tell a friend

    Love Neowin? Tell a friend!