+ Post New Thread
Results 1 to 5 of 5
Coding Thread, Default printer BAT in Coding and Web Development; anyone know how to set the default printer to the local printer, if its present?? i currently run a batch ...
  1. #1
    tommccann's Avatar
    Join Date
    Jun 2009
    Posts
    252
    Thank Post
    46
    Thanked 39 Times in 31 Posts
    Rep Power
    0

    Default printer BAT

    anyone know how to set the default printer to the local printer, if its present??
    i currently run a batch script that maps network drives, any idea how to set the locally installed printer to default without manually doing it?

    maybe deleting all the network printers would set the local as default, then mapping the network printers again????

    .COM!

  2. #2
    apeo's Avatar
    Join Date
    Sep 2005
    Location
    Lost
    Posts
    1,612
    Thank Post
    95
    Thanked 115 Times in 111 Posts
    Rep Power
    41
    The following vbscript should do it:

    Code:
    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
    This assumes printer is installed on port LPT1: or USB001.

  3. Thanks to apeo from:

    tommccann (10th March 2010)

  4. #3
    tommccann's Avatar
    Join Date
    Jun 2009
    Posts
    252
    Thank Post
    46
    Thanked 39 Times in 31 Posts
    Rep Power
    0
    Lovely jubbly!! Cheers

  5. #4
    danrhodes's Avatar
    Join Date
    Sep 2008
    Location
    Wath Upon Dearne
    Posts
    1,513
    Thank Post
    157
    Thanked 181 Times in 150 Posts
    Rep Power
    67
    You can use the following to do it remotly.

    RUNDLL32 PRINTUI.DLL,PrintUIEntry /c \\ICT1-01 /ga /n "\\server2.curriculum.airedalehigh.com\ITC-1"
    RUNDLL32 PRINTUI.DLL,PrintUIEntry /c \\ICT1-01 /y /n "\\server2.curriculum.airedalehigh.com\ITC-1"

    2 stage's first on add's seconds sets as default.

    D

  6. #5
    paulst30's Avatar
    Join Date
    Jan 2010
    Location
    Glasgow
    Posts
    20
    Thank Post
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0
    We currently use a logon script that points to a registry file on the C drive of the pc. Its an export of the default printer setting. So when the logon script reads this file it plants the registry key and defaults to that printer.

    for example we use Kix32 as our logon script

    If EXIST ("c:\hplj.txt") = 1
    shell "cmd /c @LDRIVE\logonscripts\printers\hplj.bat"
    ?"Default Printer Set...."
    EndIf

    Bat file contents

    c:\windows\regedit /s c:\hplj.reg

    reg file on C drive contents (hplj.reg)

    Windows Registry Editor Version 5.00

    [HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows]
    "DebugOptions"="2048"
    "Documents"=""
    "DosPrint"="no"
    "load"=""
    "NetMessage"="no"
    "NullPort"="None"
    "Programs"="com exe bat pif cmd"
    "Device"="Admin_Mono,winspool,Ne00:"


    So in short, i export the above registry key to the C drive as hplj.reg (could be named anything you want) The person logs in and this file changes the default printer.

SHARE:
+ Post New Thread

Similar Threads

  1. Default Printer Batch File
    By karldenton in forum Windows
    Replies: 13
    Last Post: 23rd March 2010, 05:16 PM
  2. Default Printer Error
    By finney_83 in forum Windows
    Replies: 3
    Last Post: 3rd November 2009, 09:19 AM
  3. Default Printer Everywhere
    By karldenton in forum Windows
    Replies: 3
    Last Post: 21st July 2008, 08:50 PM
  4. Replies: 13
    Last Post: 20th February 2008, 04:29 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
  •