Alex's Weblog

Weblog di Ermanno Goletto (Codename Alex - A Learning EXperience)
posts - 438, comments - 4214, trackbacks - 294

My Links

News

Il blog è stato
trasferito al
 seguente link:


DevAdmin Blog

Add my blog to Live

Foto

Curriculum Vitae


Il contenuto di questo blog e di ciascun post viene fornito “così come é”, senza garanzie, e non conferisce alcun diritto. Questo blog riporta il mio personale pensiero che non riflette necessariamente il pensiero del mio datore di lavoro.

Logo Creative Commons Deed


Logo MCTS

Logo MCSA

Logo MCP

Logo Microsoft Certified Business Management Solutions Professional

Microsoft Certified Business Management Solutions Specialist


Logo UGIdotNET UGIdotNET Contributor


Logo UGISS UGISS Contributor


Logo SysAdmin.it SysAdmin.it Staff


Article Categories

Archives

Post Categories

Blogs

Database

Development

Friends

IT

Knowledge Base

Links

MBS

MCP

MVP Sites

User Groups

Virtualization

Elencare i print job tramite WMI

Uno snippet per i print job in corso.

Dim path As New System.Management.ManagementPath("root\cimv2")
Dim options As New System.Management.ConnectionOptions

'Local Host
path.Server = "."

'Remote Host
'path.Server = "ServerName"
'options.Username = "DomainName\UserName"
'options.Password = "UserPassword"

Dim scope As New System.Management.ManagementScope(path, options)
Dim query As New System.Management.ObjectQuery( _
       "SELECT Name, Document, JobStatus, Owner, TotalPages, Size, TimeSubmitted FROM Win32_PrintJob")
Dim search As New System.Management.ManagementObjectSearcher(scope, query)
Dim objectCollection As System.Management.ManagementObjectCollection

objectCollection = search.Get()

Dim printerName, document, owner As String
Dim pages, size As System.UInt32
Dim timeSubmitted As DateTime
For Each prntJob As System.Management.ManagementObject In objectCollection
       printerName = prntJob("Name").ToString().Split(","c)(0)
       document = prntJob("Document").ToString()
       owner = prntJob("Owner").ToString()
       pages = System.Convert.ToUInt32(prntJob("TotalPages"))
       size = System.Convert.ToUInt32(prntJob("Size"))
       timeSubmitted = System.Management.ManagementDateTimeConverter.ToDateTime( _
                prntJob("TimeSubmitted").ToString())

       Console.WriteLine("Printer: " & printerName)
       Console.WriteLine("Document: " & document)
       Console.WriteLine("Owner: " & owner)
       Console.WriteLine("Pages: " & IIf(pages = 0, "N/D", pages.ToString("#,##0")).ToString())
       Console.WriteLine("Size: " & System.Convert.ToInt32(size / 1024).ToString("#,##0") & " KB")
       Console.WriteLine("Submitted: " & timeSubmitted.ToString("G"))

       Console.WriteLine(New String("-"c, 50))
Next

Per approfondimenti si vedano i seguenti link:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_printjob.asp
http://support.microsoft.com/kb/836877/en-us

Print | posted on mercoledì 23 agosto 2006 15:29 | Filed Under [ Links Code & Snippet ]

Feedback

Gravatar

# re: Elencare i print job tramite WMI

Il codice in realtà l'ho scritto in VB2005, ma per usare System.Management devi aggiungere il relativo Reference.
24/08/2006 17:06 | Alex
Gravatar

# mvp hats

The actual 206 single lb area leaped your Some.Fifty eight 40-yard dash with the NFL mvp hats Put together.Using Charles Tillman and Tim Jennings the particular very likely beginners proceeding into 2012, Fleming could be utilised mainly with unique competitors.


22/06/2012 07:31 | mvp hats
Comments have been closed on this topic.

Powered by:
Powered By Subtext Powered By ASP.NET