• 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

    • Hope they laid off whatever middle managers thought it was a good idea to rebrand AAD as "Microsoft Entra ID" and Yammer as "Viva Engage," costing Microsoft some valuable brand recognition.
    • Microsoft removes PowerShell 2.0 from Windows 11 in build 27891 by Taras Buria Microsoft has released a new Windows 11 preview build from the Canary Channel. Build 27891 is out with several improvements and fixes, a new feature for the Microsoft Store, and the removal of PowerShell 2.0, which is now deprecated. Microsoft deprecated PowerShell 2.0 all the way back in Windows 10 version 1709. Last month, it issued a reminder about it, and now, PowerShell 2.0 is gone from the latest Windows 11 Canary builds. Microsoft says it will publish more information about PowerShell 2.0 removal in the upcoming update for Windows 11. Also, Microsoft is rolling out a new update for the Microsoft Store. Version 22406 is rolling out to Windows Insiders in the Canary and Dev Channels, offering the ability to install a product right from the Store's home page, as seen in the screenshot below: Here is what was fixed: [General] We fixed the issue causing the “Reset this PC” option under Settings > System > Recovery to not work after upgrading the last few Canary Channel builds. Fixed the underlying issue which was causing the taskbar to unexpectedly not showing acrylic material after upgrading to the latest Canary builds. This also impacted a few other scenarios, leading to unexpected black or white in some UI. Fixed an underlying issue believed to be the cause of some Insiders seeing Windows update downloads to get stuck at 2% recently. Fixed a few more languages including Vietnamese and Arabic that were still having issues with certain characters not rendering correctly for Insiders after the latest builds, causing nonsense to display in places like Task Manager and more. This impacted characters outside of A-Z. [File Explorer] Fixed an issue where if you opened the “…” menu in the File Explorer address bar to show the full list of folders for the current path, the dropdown might be cut off and the bottom of it inaccessible. [Settings] Fixed an issue in the previous build which could cause Settings to crash when opening microphone properties under Settings > System > Sound. Fixed an underlying issue related to Bluetooth which could cause Settings or Quick Settings to crash on launch for some people. [Windowing] Fixed an issue which was causing the window minimizing animation to not display correctly in the previous flight. [Task Manager] Fixed an issue where the CPU graphs in the Performance page were still using the old CPU utility calculations. Fixed an issue where after adding the new CPU Utility column, you might notice that System Idle Process always showed as 0. [Audio] Fixed an issue which could cause all system sounds to stop working (for example notification alert sound and the sound that plays when clicking the volume slider in quick settings), although audio in general was working on your PC. [Other] Fixed an underlying issue which was causing fonts in certain app menu items to unexpectedly appear corrupted or overlapped for some people. This also impacted typing in Word – where when using Hebrew a period may unexpectedly show as a 3, and in Thai typing space may show a 2. Fixed an underlying issue which could cause the playback controls in Media Player to become distorted in the latest Canary flights. Fixed an underlying issue believed to be the cause of LDAP queries from apps to take an unexpectedly long time in the previous flight. Fixed an issue which could cause print previews to appear slightly blurry in recent Canary flights. Here is the list of known issues: [General] [IMPORTANT NOTE FOR COPILOT+ PCs] If you are joining the Canary Channel on a new Copilot+ PC from the Dev Channel, Release Preview Channel or retail, you will lose Windows Hello pin and biometrics to sign into your PC with error 0xd0000225 and error message “Something went wrong, and your PIN isn’t available”. You should be able to re-create your PIN by clicking “Set up my PIN”. [Settings] [NEW] We’re investigating an issue in this build which could cause Settings to crash when interacting with the options under Settings > System > Power & Battery. [Remote Desktop] [NEW] You may see extreme graphical distortion and rendering issues using remote desktop on Arm64 PCs in this build. You can find full release notes for build 27891 in a post on the official Windows Blogs website.
    • Sounds like corporate spamming being painted as a "feature"...so long as it can be blocked like any other random creep messaging you, no biggie.
    • Don't really like these kinds of games but that song is nice.
  • Recent Achievements

    • Week One Done
      Devesh Beri earned a badge
      Week One Done
    • Week One Done
      956400 earned a badge
      Week One Done
    • 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
  • Popular Contributors

    1. 1
      +primortal
      470
    2. 2
      ATLien_0
      159
    3. 3
      +FloatingFatMan
      151
    4. 4
      Nick H.
      66
    5. 5
      +thexfile
      62
  • Tell a friend

    Love Neowin? Tell a friend!