Sign in to follow this  
Followers 0
BoogY

Help with file

4 posts in this topic

Hi there to all of you :mellow:

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by 99ojo

Share this post


Link to post
Share on other sites

Merci beaucoup :mellow:

Share this post


Link to post
Share on other sites

Merci beaucoup :mellow:

pas de problem.

;-))

Stefan

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0