Convert Script code to VB.Net

A

Allen

Given a script like the following is there a recipe I could use to convert
it to VB.net code.'myServer = "."'The following moniker identifies the
root\cimv2 namespace on the myServer computer. An SWbemServices object is
returned.'objWMIService = GetObject("winmgmts:\\" & myServer &
"\root\cimv2")'colItems = objWMIService.ExecQuery("Select * from
Win32_Processor")'For Each objItem In colItems' Wscript.Echo("Processor Id:
" & objItem.ProcessorId)' Wscript.Echo("Maximum Clock Speed: " &
objItem.MaxClockSpeed)'NextI tried the following but don't really know why
it works.The parameter for GetObject is a path name to a file.What does the
path I used point to?Dim strComputer As String = "."Dim objWMIService As
Object = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")Dim colItems
As Object = objWMIService.ExecQuery("Select * from Win32_Processor")For Each
objItem As Object In colItemsConsole.WriteLine("Processor Id: " &
objItem.ProcessorId)Console.WriteLine("Maximum Clock Speed: " &
objItem.MaxClockSpeed)NextInstead of Object are there .Net types that can be
used for this script?In general, given a script how does one determine the
types to use?I know I'm asking for a lot and I'd be appreciative for partial
answers or any help at all.Thanks
 
A

Allen

I've no idea what happed to the previous post.
Here it is again.

Given a script like the following is there a recipe I could use to convert
it to VB.net code.

'myServer = "."
'objWMIService = GetObject("winmgmts:\\" & myServer &
"\root\cimv2")
'colItems = objWMIService.ExecQuery("Select * from
Win32_Processor")
'For Each objItem In colItems' Wscript.Echo("Processor Id:
" & objItem.ProcessorId)' Wscript.Echo("Maximum Clock Speed: " &
objItem.MaxClockSpeed)
'Next

I tried the following but don't really know why it works.
The parameter for GetObject is a path name to a file.What does the
path I used point to?

Dim strComputer As String = "."Dim objWMIService As
Object = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Dim colItems As Object =
objWMIService.ExecQuery("Select * from Win32_Processor")
For Each objItem As Object In colItemsConsole.
WriteLine("Processor Id: " &
objItem.ProcessorId)Console.
WriteLine("Maximum Clock Speed: " &
objItem.MaxClockSpeed)
Next

Instead of Object are there .Net types that can be
used for this script?In general, given a script how does one determine the
types to use?

I know I'm asking for a lot and I'd be appreciative for partial
answers or any help at all.Thanks
 
A

Allen

You never had to use
Dim objWMIService As Object = GetObject("winmgmts:\\" & strComputer &
"\root\cimv2")
Do you know what that does?


Nice site
Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top