BoogY Posted February 25, 2010 Share Posted February 25, 2010 Hi there to all of you I have a big problem with this bat file : START PDFCreator START Microsoft XPS Document Writer START \\SERVER\Printer_05 START \\SERVER\Printer_06 START \\SERVER\Printer_07 START \\SERVER\Printer_08 START \\SERVER\Printer_09 START \\SERVER\Printer_10 START \\SERVER\Printer_11 I have a script that exports all the printers of the user un this bat file and after i want to run 'it so I'll get the same net printers installed automaticaly. The script is working but i dont know how to edit the file once created and remove (Comment out) all the printers that are not on the network (local printers) Here is the function that exports all the printers : $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = @ComputerName $Output="" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Printer", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems $Output = $Output & "START " & $objItem.Caption & @CRLF Next FileWrite($Dest & "\" & $prof &"_Printers.bat", $Output ) Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_Printer" ) Endif EndFunc Thanks a lot for your help cause this is rely urgent Link to comment Share on other sites More sharing options...
99ojo Posted February 25, 2010 Share Posted February 25, 2010 (edited) Hi, this should work, if you want to get rid of: START PDFCreator START Microsoft XPS Document Writer change For $objItem In $colItems $Output = $Output & "START " & $objItem.Caption & @CRLF Next to For $objItem In $colItems If StringinStr ($objItem.Caption, "\\") Then $Output = $Output & "START " & $objItem.Caption & @CRLF Next ;-)) Stefan Edited February 25, 2010 by 99ojo Link to comment Share on other sites More sharing options...
BoogY Posted February 25, 2010 Author Share Posted February 25, 2010 Merci beaucoup Link to comment Share on other sites More sharing options...
99ojo Posted February 25, 2010 Share Posted February 25, 2010 Merci beaucoup pas de problem.;-))Stefan Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now