|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
WMI ConversionCan anyone tell me what the script below is in VB.NET WMI format? strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colInstalledPrinters = objWMIService.ExecQuery _ ("Select * from Win32_Printer") For Each objPrinter in colInstalledPrinters objPrinter.CancelAllJobs() Next ------------------------------------------ If I try to convert this then I make 'objPrinter' a ManagementObject, but then I have 'Delete' & not 'CancelAllJobs'. Any suggestions? Hi,
Add a reference to system.management to your application. Dim moReturn As Management.ManagementObjectCollection Dim moSearch As Management.ManagementObjectSearcher Dim mo As Management.ManagementObject moSearch = New Management.ManagementObjectSearcher("Select * from Win32_Printer") moReturn = moSearch.Get For Each mo In moReturn mo.InvokeMethod("CancelAllJobs", Nothing) Trace.WriteLine(mo("Name").ToString) Next Ken ----------------- Show quoteHide quote "MildManoredJanitor" <hongk***@phoey.fun> wrote in message news:uJfP423PGHA.1688@TK2MSFTNGP11.phx.gbl... > Hello Group > > Can anyone tell me what the script below is in VB.NET WMI format? > > strComputer = "." > Set objWMIService = GetObject("winmgmts:" _ > & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") > > Set colInstalledPrinters = objWMIService.ExecQuery _ > ("Select * from Win32_Printer") > > For Each objPrinter in colInstalledPrinters > objPrinter.CancelAllJobs() > Next > > ------------------------------------------ > > If I try to convert this then I make 'objPrinter' a ManagementObject, but > then I have 'Delete' & not 'CancelAllJobs'. > > Any suggestions? > > Thanks Ken
Basically, my code was the same as yours with one exception: mo.InvokeMethod("CancelAllJobs", Nothing) Much Appreciated Show quoteHide quote "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message news:%23$mkpS4PGHA.2912@tk2msftngp13.phx.gbl... > Hi, > > Add a reference to system.management to your application. > > Dim moReturn As Management.ManagementObjectCollection > Dim moSearch As Management.ManagementObjectSearcher > Dim mo As Management.ManagementObject > > moSearch = New Management.ManagementObjectSearcher("Select * from > Win32_Printer") > moReturn = moSearch.Get > > For Each mo In moReturn > mo.InvokeMethod("CancelAllJobs", Nothing) > Trace.WriteLine(mo("Name").ToString) > Next > > Ken > ----------------- > "MildManoredJanitor" <hongk***@phoey.fun> wrote in message > news:uJfP423PGHA.1688@TK2MSFTNGP11.phx.gbl... > > Hello Group > > > > Can anyone tell me what the script below is in VB.NET WMI format? > > > > strComputer = "." > > Set objWMIService = GetObject("winmgmts:" _ > > & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") > > > > Set colInstalledPrinters = objWMIService.ExecQuery _ > > ("Select * from Win32_Printer") > > > > For Each objPrinter in colInstalledPrinters > > objPrinter.CancelAllJobs() > > Next > > > > ------------------------------------------ > > > > If I try to convert this then I make 'objPrinter' a ManagementObject, but > > then I have 'Delete' & not 'CancelAllJobs'. > > > > Any suggestions? > > > > > >
Is it worth while in developing VB.NET or C#.NET
tranferring data from Access to SQL Server Express USB Pen Drive Detection - Retrieving Baffeled by Treeview Nodes Index!!!!! crazy UserControl Class in a module or class in a class? Problem with Hashtable Multiple references in the same project. Very Unpredictable ListBox Behaviour Adding New member to TextBox.. |
|||||||||||||||||||||||