• 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

    • The only thing it looks like to me is harder to read.
    • I am surprised that the kid who got run over next to stop light did not sue...
    • Wine 10.10 released, brings updated Mono engine, bug fixes for several games, and more by David Uzondu Nearly two weeks after Wine 10.9 dropped, Wine 10.10 is here with an updated Mono engine and the complete removal of a major graphics dependency. The Wine Mono engine, which provides .NET Framework support, has been bumped to version 10.1.0. Another major change is the removal of the OSMesa library as a dependency. OpenGL rendering on memory device contexts will now be handled by a pbuffer, cleaning up the graphics stack. Here are other notable changes with this release: More support for generating Windows Runtime metadata in WIDL. Locale data updated to Unicode CLDR 47. P010 format support in Media Foundation. Of course, no development release would be complete without a boatload of bug fixes. This version crushes a total of 38 bugs, addressing problems in a wide range of applications and games. Gamers will be pleased to see fixes for titles like F.E.A.R., S.T.A.L.K.E.R.: Anomaly, and StarCraft Remastered. Issues that caused a black screen in Steam's Big Picture mode and crashes when starting a new game in F.E.A.R. have been resolved. The fixes go way back, even tackling issues in ancient software like Lotus Freelance Graphics 2.1 and input problems in the classic indie game Braid. Here's the full list of game-related issues addressed: Rise of Nations: Both mouse buttons were required for a single left-click Braid: Both Shift keys needed to move puzzle pieces F.E.A.R: Crashed with an "Out of memory" error when starting a new game F.E.A.R Combat: Black screen at startup due to memory error S.T.A.L.K.E.R. Anomaly: Crashed when loading into a save file StarCraft Remastered: Game wouldn't start with Wine 10.5 Unreal II: Hangs with a black screen when switching to 1440x900 resolution Eador. Masters of the Broken World: Bad map textures after starting the game Horizon Chase: Freezes on startup The Fidelio Incident and Vampyr: Beeping noise on exit Burger Shop: Shifted to the top left corner in fullscreen mode And here's the rest of the issues that were fixed: Lotus Freelance Graphics 2.1: Hangs at the splash screen HTML-Kit 292: Tab bar isn't fully visible without scrolling at 96 DPI Tab completion for cmd: Improvements made regedit: Binary values editor layout is broken and .reg files couldn’t be imported Baofeng5-5.31.1128: Welcome window crashes on start Canon printer driver installation now works Steam Big Picture mode: Fixed black screen when using d3d10 Noteworthy Composer: Crashes in winealsa resolved Ricoh Digital Camera Utility 5: Crashes when switching between Browser and Laboratory modes Wondershare Uniconverter 13: Characters now display properly AVCLabs Video Enhancer AI: No longer crashes on start New thread stack memory usage optimized PlayOnline Viewer: Window now properly activates after being minimized Virtual desktop behavior fixed secur32:ntlm tests now pass on Windows 11 24H2 d3d9:device WM_WINDOWPOSCHANGED test no longer fails on Linux GitLab CI no longer crashes in various multimedia tests HP Prime Virtual Calculator: Fixed startup crash Qt Installer for Windows: Now functions correctly SHIFT-based range selection logic corrected Creating 64-bit wineprefix with old wow64 now possible Regression from realloc switch fixed (memory now zeroed as expected) RTTI now works on arm32 after recent changes Smartsuite 3.1 installer no longer crashes Fixed possible use-after-free in dbghelp's symt_add_func_line Build issues with clang for x86_64 resolved due to RTTI changes You can read the full release notes here. The source code for this release is also available. To get started, follow the installation instructions for your platform: Ubuntu/Debian, Fedora, or macOS.
    • Nice! I hate the chop shop approach as well.
  • Recent Achievements

    • Week One Done
      Simmo3D earned a badge
      Week One Done
    • One Month Later
      Simmo3D earned a badge
      One Month Later
    • One Month Later
      greege earned a badge
      One Month Later
    • Week One Done
      greege earned a badge
      Week One Done
    • Week One Done
      LagFighterZ earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      547
    2. 2
      ATLien_0
      232
    3. 3
      +FloatingFatMan
      165
    4. 4
      Michael Scrip
      119
    5. 5
      +Edouard
      91
  • Tell a friend

    Love Neowin? Tell a friend!