• 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

    • so you just moved data to onedrive? Or did you upgrade the disk? I see multiple options either actual SSD or NVME options on amazon for around 50 bucks.. If you are low on space, and after a cleanup/purge of you stuff you don't need your still low it would be good idea to upgrade to bigger drive.  As to /sageset:65535, I don't think that value is valid https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cleanmgr Displays the Disk Cleanup Settings dialog box and also creates a registry key to store the settings that you select. The n value, which is stored in the registry, allows you to specify tasks for Disk Cleanup to run. The n value can be any integer value from 0 to 9999. For more information, see Registry key information. So I would guess trying to use such a high value wouldn't store your settings.. You sure do not need  to use sageset or sagerun to run the disk cleanup..  That is for running it later with the same setting you pick when you set it. 
    • Yes while it's still a great browser it seems bloated more with each update by things I'm not the least interested in
    • We now know why Nvidia blocked yet another review, the new RTX 5050 is apparently terrible by Sayan Sen With its latest RTX 5000 series of GPUs, Nvidia has not been transparent with how its cards perform. The company did not ship review drivers for the RTX 5060 on launch day and has repeated the same deed with the new RTX 5050 as well. For those who may not have followed, Nvidia unveiled the GeForce RTX 5050 last month for $249 and released the Game Ready driver for the card this month with version 576.88. As such, the RTX 5050 has now been tested by Korean site Quasar Zone where the GPU has been compared against other cards that are priced around that same bracket. The site has found that Nvidia's new entry-level offering is worse than Intel's Arc B580, a card that launched around six months ago for the same price. As you can see in the image above, the Arc B580 was slightly faster on average. The biggest gap between the two was on Path of Exile 2. Another point in favor of the Arc GPU is that it has 12 Gigs of video memory whereas the RTX 5050 only has 8 GB. The 5050 was also pitted against Nvidia's last gen RTX 4060 as well as AMD's RX 7600, both of which are also 8 Gig cards. The 7600 is often found at around $250 these days while the RTX 4060 frequents around $275. The RTX 5050 is essentially neck and neck with the 4060 and is ever so slightly faster than the RX 7600. Once again this just highlights that Nvidia is essentially giving the same kind of performance that Intel and AMD GPUs have provided since last year or so. In fact, if we consider the Radeon RX 6600 and 6650 XT GPUs, which have been available for around $180 to $220 in the past, it becomes clearer just how bad of a value the RTX 5050 is as those 6000 series AMD cards probably get pretty close to the 5050 in rasterization throughput. Chances of something like "Fine Wine" are also slim given that the RTX 5050 just does not seem to have the hardware resources to pull off something like that later in this lifespan. If anything, we are more likely to see that happen from the Intel B580 GPU or AMD's $299 RX 9060 (there is already evidence of that). Source and images: Quasar Zone
    • A messaging network full of adult content. Ewww. 🤮
  • Recent Achievements

    • First Post
      loose_observer earned a badge
      First Post
    • Week One Done
      BeeJay_Balu earned a badge
      Week One Done
    • Week One Done
      filminutz earned a badge
      Week One Done
    • Reacting Well
      SteveJaye earned a badge
      Reacting Well
    • One Month Later
      MadMung0 earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      444
    2. 2
      ATLien_0
      161
    3. 3
      +FloatingFatMan
      145
    4. 4
      Nick H.
      65
    5. 5
      +thexfile
      62
  • Tell a friend

    Love Neowin? Tell a friend!