+ Post New Thread
Results 1 to 6 of 6
Windows Thread, Bat file coding in Technical; hi guys, anyone know how to check for a printer on usb then set it as default, must be BAT ...
  1. #1
    tommccann's Avatar
    Join Date
    Jun 2009
    Posts
    252
    Thank Post
    46
    Thanked 39 Times in 31 Posts
    Rep Power
    0

    Bat file coding

    hi guys, anyone know how to check for a printer on usb then set it as default, must be BAT format tho sadly because i want it to fit in to my current script. we currently map and default network printers like this: IF %Location% == itsuite \\Domain\netlogon\CON2PRT /CD \\Domain\suite
    using a enivronment variable to set locations.

    Any ideas??

    Thanks

  2. #2
    neon's Avatar
    Join Date
    Apr 2009
    Location
    Market Harborough
    Posts
    222
    Thank Post
    7
    Thanked 22 Times in 20 Posts
    Rep Power
    15
    could you not write the code in .vbs and write a line in your .bat file to call the .vbs?

  3. #3
    tommccann's Avatar
    Join Date
    Jun 2009
    Posts
    252
    Thank Post
    46
    Thanked 39 Times in 31 Posts
    Rep Power
    0
    if you could tell me how to call a vbs from a bat then yea i suppose

  4. #4
    neon's Avatar
    Join Date
    Apr 2009
    Location
    Market Harborough
    Posts
    222
    Thank Post
    7
    Thanked 22 Times in 20 Posts
    Rep Power
    15
    call "\\servername\sharename\vbsname.vbs"

    think it will be easier to do it in .vbs than a .bat file? think you would have to install extras to acheive this from a .bat script.

  5. Thanks to neon from:

    tommccann (31st March 2010)

  6. #5
    tommccann's Avatar
    Join Date
    Jun 2009
    Posts
    252
    Thank Post
    46
    Thanked 39 Times in 31 Posts
    Rep Power
    0
    Dim oPrinters

    Set shell= WScript.CreateObject("WScript.Shell")
    Set WshNetwork = WScript.CreateObject("WScript.Network")
    Set oPrinters = WshNetwork.EnumPrinterConnections


    For i = 0 to oPrinters.Count - 1 Step 2
    if oPrinters.Item(i) = "LPT1:" then
    wshnetwork.setdefaultprinter oPrinters.Item(i)
    elseif oPrinters.Item(i) = "USB001" then
    wshnetwork.setdefaultprinter oPrinters.Item(i)
    end if
    Next


    then called in the bat, o that was easier than i thought! cheers

  7. #6
    neon's Avatar
    Join Date
    Apr 2009
    Location
    Market Harborough
    Posts
    222
    Thank Post
    7
    Thanked 22 Times in 20 Posts
    Rep Power
    15
    yh, i was looking for the code to send you, on easter hols for 2 weeks so couldnt get hold of it...

    try this website Logon Script Printer - AddWindowsPrinterConnection VBScript Method is quite good for things like this...



SHARE:
+ Post New Thread

Similar Threads

  1. Sims permissions bat file
    By ful56_uk in forum MIS Systems
    Replies: 21
    Last Post: 24th April 2010, 09:53 PM
  2. .bat file clear old files
    By T_Noble in forum Coding
    Replies: 3
    Last Post: 20th January 2010, 01:03 PM
  3. BAT File issue
    By Danny159 in forum Windows Vista
    Replies: 2
    Last Post: 14th March 2009, 02:54 PM
  4. Stopping SQL using a Bat file
    By ful56_uk in forum Windows
    Replies: 4
    Last Post: 7th April 2008, 01:09 AM
  5. Need some Coding
    By russdev in forum Web Development
    Replies: 5
    Last Post: 11th November 2006, 11:49 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •