|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Convert Script code to VB.NetGiven 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 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 Allen,
See this link on our website. I thought that it is almost what your want. http://www.vb-tips.com/default.aspx?ID=632054ab-5fe5-4779-a6be-111ae0c748f2 There are more WMI tips search for that just on WMI I hope this helps, Cor Show quoteHide quote "Allen" <allen99NOSPAM@a-znet.com> schreef in bericht news:%23JmvWyUQGHA.564@TK2MSFTNGP12.phx.gbl... > 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 > > > You never had to use
Dim objWMIService As Object = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Do you know what that does? Nice site Thanks Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:eZieG2UQGHA.1868@TK2MSFTNGP09.phx.gbl... > Allen, > > See this link on our website. > I thought that it is almost what your want. > > http://www.vb-tips.com/default.aspx?ID=632054ab-5fe5-4779-a6be-111ae0c748f2 > > There are more WMI tips search for that just on WMI > > I hope this helps, > > Cor > > "Allen" <allen99NOSPAM@a-znet.com> schreef in bericht > news:%23JmvWyUQGHA.564@TK2MSFTNGP12.phx.gbl... >> 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 >> >> >> > >
VSTO 2005 - Read Range from excel
Create application to extract data from excel sheet How can we mail some file without mentioning the SMTP server addre Treeview population directly from MSAccess OOP / 3-Tier development questions VB.NET 2005 & XML writing custom event for minimise, restore and close buttons How to create a Service to Log Application Names Macros too slow ! Re: "Visual Web Developer does not support creating Web sites on a |
|||||||||||||||||||||||