Author | Topic: VBScript | |
---|---|---|
Altiy Zemlytskiy | VBScript on Fri, 31 Aug 2012 15:52:52 +0300 <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body bgcolor="#FFFFFF" text="#000000"> <br> Hi all,<br> <br> trying to translate VBScript below to xBase, but unsuccessful. I did not find any way to get objWMIService. Do somebody have any idea?<br> <br> Many thanks in advance.<br> -- <br> <div class="moz-signature">Best regards, Altiy</div> <br> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <!--[if gte mso 9]><xml> <o:OfficeDocumentSettings> <o:AllowPNG/> </o:OfficeDocumentSettings> </xml><![endif]--><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:TrackMoves/> <w:TrackFormatting/> <w:PunctuationKerning/> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:DoNotPromoteQF/> <w:LidThemeOther>RU</w:LidThemeOther> <w:LidThemeAsian>X-NONE</w:LidThemeAsian> <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:SplitPgBreakAndParaMark/> <w:EnableOpenTypeKerning/> <w:DontFlipMirrorIndents/> <w:OverrideTableStyleHps/> </w:Compatibility> <w:DoNotOptimizeForBrowser/> <m:mathPr> <m:mathFont m:val="Cambria Math"/> <m:brkBin m:val="before"/> <m:brkBinSub m:val="--"/> <m:smallFrac m:val="off"/> <m:dispDef/> <m:lMargin m:val="0"/> <m:rMargin m:val="0"/> <m:defJc m:val="centerGroup"/> <m:wrapIndent m:val="1440"/> <m:intLim m:val="subSup"/> <m:naryLim m:val="undOvr"/> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true" DefSemiHidden="true" DefQFormat="false" DefPriority="99" LatentStyleCount="267"> <w:LsdException Locked="false" Priority="0" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Normal"/> <w:LsdException Locked="false" Priority="9" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="heading 1"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/> <w:LsdException Locked="false" Priority="39" Name="toc 1"/> <w:LsdException Locked="false" Priority="39" Name="toc 2"/> <w:LsdException Locked="false" Priority="39" Name="toc 3"/> <w:LsdException Locked="false" Priority="39" Name="toc 4"/> <w:LsdException Locked="false" Priority="39" Name="toc 5"/> <w:LsdException Locked="false" Priority="39" Name="toc 6"/> <w:LsdException Locked="false" Priority="39" Name="toc 7"/> <w:LsdException Locked="false" Priority="39" Name="toc 8"/> <w:LsdException Locked="false" Priority="39" Name="toc 9"/> <w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/> <w:LsdException Locked="false" Priority="10" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Title"/> <w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/> <w:LsdException Locked="false" Priority="11" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/> <w:LsdException Locked="false" Priority="22" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Strong"/> <w:LsdException Locked="false" Priority="20" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/> <w:LsdException Locked="false" Priority="59" SemiHidden="false" UnhideWhenUsed="false" Name="Table Grid"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/> <w:LsdException Locked="false" Priority="1" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 1"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 1"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 1"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/> <w:LsdException Locked="false" Priority="34" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/> <w:LsdException Locked="false" Priority="29" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Quote"/> <w:LsdException Locked="false" Priority="30" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 1"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 1"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 2"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 2"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 2"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 2"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 2"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 3"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 3"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 3"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 3"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 3"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 4"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 4"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 4"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 4"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 4"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 5"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 5"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 5"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 5"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 5"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 6"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 6"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 6"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 6"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 6"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/> <w:LsdException Locked="false" Priority="19" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/> <w:LsdException Locked="false" Priority="21" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/> <w:LsdException Locked="false" Priority="31" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/> <w:LsdException Locked="false" Priority="32" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/> <w:LsdException Locked="false" Priority="33" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Book Title"/> <w:LsdException Locked="false" Priority="37" Name="Bibliography"/> <w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/> </w:LatentStyles> </xml><![endif]--><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Обычная таблица"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:EN-US;} </style> <![endif]--> <p class="MsoPlainText">' PrinterWMI.vbs<o:p></o:p></p> <p class="MsoPlainText">' Sample WMI Printer VBScript to interrogate properties ' Author Guy Thomas <a href="http://computerperformance.co.uk/">http://computerperformance.co.uk/</a> ' Version 2.3 - December 2010 ' -----------------------------------------------' <o:p></o:p></p> <p class="MsoPlainText">Option Explicit<o:p></o:p></p> <p class="MsoPlainText">Dim objWMIService, objItem, colItems, strComputer, intPrinters<o:p></o:p></p> <p class="MsoPlainText"><o:p> </o:p></p> <p class="MsoPlainText">strComputer ="."<o:p></o:p></p> <p class="MsoPlainText">intPrinters = 1<o:p></o:p></p> <p class="MsoPlainText"><o:p> </o:p></p> <p class="MsoPlainText">' --------------------------------------------<o:p></o:p></p> <p class="MsoPlainText">' Pure WMI Section<o:p></o:p></p> <p class="MsoPlainText">Set objWMIService = GetObject _<o:p></o:p></p> <p class="MsoPlainText">("winmgmts:\\" & strComputer & "\root\CIMV2") Set colItems = objWMIService.ExecQuery _<span style="mso-spacerun:yes"> </span>("SELECT * FROM Win32_Printer")<o:p></o:p></p> <p class="MsoPlainText"><o:p> </o:p></p> <p class="MsoPlainText">'Call Wait() ' Goto Sub Routine at the end<o:p></o:p></p> <p class="MsoPlainText"><o:p> </o:p></p> <p class="MsoPlainText">' On Error Resume Next<o:p></o:p></p> <p class="MsoPlainText">For Each objItem In colItems<o:p></o:p></p> <p class="MsoPlainText"><span style="mso-spacerun:yes"> </span>WScript.Echo "Printers on " _<o:p></o:p></p> <p class="MsoPlainText"><span style="mso-spacerun:yes"> </span>& objItem.name & ", Printer Number: " & intPrinters & VbCr & _ <o:p></o:p></p> <p class="MsoPlainText"><span style="mso-spacerun:yes"> </span>"====================================" & VbCr & _ <o:p></o:p></p> <p class="MsoPlainText"><span style="mso-spacerun:yes"> </span>"Availability: " & objItem.Availability & VbCr & _<o:p></o:p></p> <p class="MsoPlainText"><span style="mso-spacerun:yes"> </span>"Description: " & objItem.Description & VbCr & _ <o:p></o:p></p> <p class="MsoPlainText"><span style="mso-spacerun:yes"> </span>"Printer: " & objItem.DeviceID & VbCr & _ <o:p></o:p></p> <p class="MsoPlainText"><span style="mso-spacerun:yes"> </span>"Driver Name: " & objItem.DriverName & VbCr & _ <o:p></o:p></p> <p class="MsoPlainText"><span style="mso-spacerun:yes"> </span>"Port Name: " & objItem.PortName & VbCr & _ <o:p></o:p></p> <p class="MsoPlainText"><span style="mso-spacerun:yes"> </span>"Printer State: " & objItem.PrinterState & VbCr & _ <o:p></o:p></p> <p class="MsoPlainText"><span style="mso-spacerun:yes"> </span>"Printer Status: " & objItem.PrinterStatus & VbCr & _ <o:p></o:p></p> <p class="MsoPlainText"><span style="mso-spacerun:yes"> </span>"PrintJobDataType: " & objItem.PrintJobDataType & VbCr & _ <o:p></o:p></p> <p class="MsoPlainText"><span style="mso-spacerun:yes"> </span>"Print Processor: " & objItem.PrintProcessor & VbCr & _ <o:p></o:p></p> <p class="MsoPlainText"><span style="mso-spacerun:yes"> </span>"Spool Enabled: " & objItem.SpoolEnabled & VbCr & _ <o:p></o:p></p> <p class="MsoPlainText"><span style="mso-spacerun:yes"> </span>"Separator File: " & objItem.SeparatorFile & VbCr & _ <o:p></o:p></p> <p class="MsoPlainText"><span style="mso-spacerun:yes"> </span>"Queued: " & objItem.Queued & VbCr & _ <o:p></o:p></p> <p class="MsoPlainText"><span style="mso-spacerun:yes"> </span>"Status: " & objItem.Status & VbCr & _ <o:p></o:p></p> <p class="MsoPlainText"><span style="mso-spacerun:yes"> </span>"StatusInfo: " & objItem.StatusInfo & VbCr & _ <o:p></o:p></p> <p class="MsoPlainText"><span style="mso-spacerun:yes"> </span>"Published: " & objItem.Published & VbCr & _ <o:p></o:p></p> <p class="MsoPlainText"><span style="mso-spacerun:yes"> </span>"Shared: " & objItem.Shared & VbCr & _ <o:p></o:p></p> <p class="MsoPlainText"><span style="mso-spacerun:yes"> </span>"ShareName: " & objItem.ShareName & VbCr & _ <o:p></o:p></p> <p class="MsoPlainText"><span style="mso-spacerun:yes"> </span>"Direct: " & objItem.Direct & VbCr & _ <o:p></o:p></p> <p class="MsoPlainText"><span style="mso-spacerun:yes"> </span>"Location: " & objItem.Location & VbCr & _ <o:p></o:p></p> <p class="MsoPlainText"><span style="mso-spacerun:yes"> </span>"Priority: " & objItem.Priority & VbCr & _ <o:p></o:p></p> <p class="MsoPlainText"><span style="mso-spacerun:yes"> </span>"Work Offline: " & objItem.WorkOffline & VbCr & _ <o:p></o:p></p> <p class="MsoPlainText"><span style="mso-spacerun:yes"> </span>"Horizontal Res: " & objItem.HorizontalResolution & VbCr & _<o:p></o:p></p> <p class="MsoPlainText"><span style="mso-spacerun:yes"> </span>"Vertical Res: " & objItem.VerticalResolution & VbCr & _ <o:p></o:p></p> <p class="MsoPlainText"><span style="mso-spacerun:yes"> </span>""<o:p></o:p></p> <p class="MsoPlainText"><span style="mso-spacerun:yes"> </span>intPrinters = intPrinters + 1<o:p></o:p></p> <p class="MsoPlainText">Next<o:p></o:p></p> <p class="MsoPlainText"><o:p> </o:p></p> <p class="MsoPlainText">sub Wait()<o:p></o:p></p> <p class="MsoPlainText">If strComputer = "." then<o:p></o:p></p> <p class="MsoPlainText">strComputer = "Local Host"<o:p></o:p></p> <p class="MsoPlainText">else strComputer = strComputer<o:p></o:p></p> <p class="MsoPlainText"><span style="mso-spacerun:yes"> </span>end if<o:p></o:p></p> <p class="MsoPlainText"><o:p> </o:p></p> <p class="MsoPlainText">WScript.Echo "Wait 2 mins for " & strComputer _ & " to enumerate printers"<o:p></o:p></p> <p class="MsoPlainText"><o:p> </o:p></p> <p class="MsoPlainText">End Sub<o:p></o:p></p> <p class="MsoPlainText"><o:p> </o:p></p> <p class="MsoPlainText">WScript.Quit<o:p></o:p></p> <p class="MsoPlainText"><o:p> </o:p></p> <p class="MsoPlainText">' End of Sample Printer VBScript<o:p></o:p></p> <meta name="ProgId" content="Word.Document"> <meta name="Generator" content="Microsoft Word 14"> <meta name="Originator" content="Microsoft Word 14"> <link rel="File-List" href="file:///C:%5CUsers%5Caltiy%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"> <link rel="themeData" href="file:///C:%5CUsers%5Caltiy%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"> <link rel="colorSchemeMapping" href="file:///C:%5CUsers%5Caltiy%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"> <style> <!-- /* Font Definitions */ @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:204; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-520092929 1073786111 9 0 415 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:EN-US;} a:link, span.MsoHyperlink {mso-style-priority:99; color:blue; mso-themecolor:hyperlink; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {mso-style-noshow:yes; mso-style-priority:99; color:purple; mso-themecolor:followedhyperlink; text-decoration:underline; text-underline:single;} p.MsoPlainText, li.MsoPlainText, div.MsoPlainText {mso-style-noshow:yes; mso-style-priority:99; mso-style-link:"Текст Знак"; margin:0cm; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; mso-bidi-font-size:10.5pt; font-family:"Calibri","sans-serif"; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:EN-US;} span.a {mso-style-name:"Текст Знак"; mso-style-noshow:yes; mso-style-priority:99; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:Текст; mso-bidi-font-size:10.5pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-hansi-font-family:Calibri;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:EN-US;} @page WordSection1 {size:612.0pt 792.0pt; margin:2.0cm 42.5pt 2.0cm 3.0cm; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.WordSection1 {page:WordSection1;} --> </style><br> <br> </body> </html> | |
Jose Antonio Diego Kereje | Re: VBScript on Fri, 31 Aug 2012 17:34:19 +0200 Hi Altiy: Here's how you can do. Regards. Diego #include 'activex.ch' PROCEDURE Main ************** Test( '.') RETURN PROCEDURE Test( cStrComputer ) ****************************** LOCAL oWmiServices, oQuery, aoPrinters IF cStrComputer == '.' cStrComputer:= 'Localhost' ENDIF On some Vista systems the WinMgmts moniker is not working as a workaround the Windows Scripting Locater which basically does internally the same as the moniker. #ifdef VISTA oWMiServices := CreateObject( 'WbemScripting.SWbemLocator' ):ConnectServer( cStrComputer, 'Root\CIMv2' ) #else oWMiServices := GetObject( 'WinMgmts:\\' + cStrComputer + '\Root\CIMV2' ) #endif oQuery := oWmiServices:ExecQuery('SELECT * FROM Win32_Printer',,48) aoPrinters := {} ComEvalCollection( oQuery, {|oI| AAdd( aoPrinters, oI )} ) FOR n:=1 TO Len( aoPrinters ) ? aoPrinters[ n ]:name + ', ' + Var2char( aoPrinters[ n ]:DriverName ) NEXT n WAIT RETURN | |
Altiy Zemlytskiy | Re: VBScript on Fri, 31 Aug 2012 19:31:39 +0300 Hi Diego, It works fine as all your hint. Many thanks! Best regards, Altiy > Hi Altiy: > > Here's how you can do. > > Regards. Diego > > > #include 'activex.ch' > > PROCEDURE Main > ************** > Test( '.') > RETURN > > PROCEDURE Test( cStrComputer ) > ****************************** > LOCAL oWmiServices, oQuery, aoPrinters > > IF cStrComputer == '.' > cStrComputer:= 'Localhost' > ENDIF > > // On some Vista systems the WinMgmts moniker is not working > // as a workaround the Windows Scripting Locater which basically > // does internally the same as the moniker. > > #ifdef _VISTA_ > oWMiServices := CreateObject( > 'WbemScripting.SWbemLocator' ):ConnectServer( cStrComputer, > 'Root\CIMv2' ) > #else > oWMiServices := GetObject( 'WinMgmts:\\' + cStrComputer + > '\Root\CIMV2' ) > #endif > > oQuery := oWmiServices:ExecQuery('SELECT * FROM Win32_Printer',,48) > > aoPrinters := {} > ComEvalCollection( oQuery, {|oI| AAdd( aoPrinters, oI )} ) > > FOR n:=1 TO Len( aoPrinters ) > ? aoPrinters[ n ]:name + ', ' + Var2char( aoPrinters[ n > ]:DriverName ) > NEXT n > WAIT > > RETURN > |