Question

Login script for printers

Asked by: chicabow

Can I add a script to log, perhaps a policy or something, that maps all the users who log in to the printers in the office. Instead of manually going to each computer and mapping the computers, it would be nice to have a policy that does this automatically. Can this be done, if so where in the policy is this controlled.
Thanks.

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2004-04-04 at 10:11:21ID20943033
Tags

script

,

printer

,

login

Topic

Windows 2003 Server

Participating Experts
14
Points
75
Comments
37

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Creating a login script to map folders and printers.
    I have a small office (13 users) running a W2K domain. I am using Active Directory and I would like help on creating a login script to map some folders and printers for users. It's not going to be a big deal to map all the folders for all the users but it would be nice to m...
  2. Losing Printer Mappings
    Have a small client with a network establised across two sites. Running SBS2003. Have just upgraded PC's from Win2K to Win/XP Pro SP2 and now the Server loses mappings to Printers on the "remote" site PC's if they are logged off. Network set up is as follows: Main...
  3. Printer mapping
    Hi all we have around 3000 + users in our facility and have two towers. We have around 60 Printers in our facility. We also have a DC in win2k3 and all the clients are windows XP and Windows 2000. we deploy the system well in advance before a new user joins in. we also need ...
  4. Edit Group Policy to remove mapped printers
    We have a sbs2003 server, with a group policy mapping printers. We to remove/edit that part of the group policy. Where in the group policy would mapped printers be located?
  5. Printer mapping when users login
    We are trying to simplify the way printers are allocated to users when they log on via active directory. Currently we have a site with printers all over the place and we want our roaming users to have the 2 nearest printers to their login location automatically mapped ready ...
  6. Map Printers
    What is the best way to map network printers on computers? GPO or SMS?

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: Fatal_ExceptionPosted on 2004-04-04 at 10:24:03ID: 10752586

So you want a script that maps the shared printer..??   Try the Net Use command in a batch file..

http://www.computerhope.com/nethlp.htm#01

 

by: chicabowPosted on 2004-04-04 at 11:38:17ID: 10752818

yes I want the user to just log in the morning and all the available printers are listed for them, printer name change and are avialable at times and sometimes not...instead of editing every user, I want this controlled via server somehow.
servername is cheffy and printer is hplaser.
so whats the syntax?

 

by: Fatal_ExceptionPosted on 2004-04-04 at 14:33:26ID: 10753491

net use LPT1: \\servername\printername /yes

 

by: chicabowPosted on 2004-04-04 at 17:43:46ID: 10754142

will test this soon,, now will I be able to "wipe" out all the printer references the current users have, then reassign using this script mentioned above?
The reason for this is because I want to rename the printers currently in the network but don't want to cause any issues or hickups.

 

by: Fatal_ExceptionPosted on 2004-04-04 at 19:09:11ID: 10754435

You should be okay with this...  TEST IT FIRST though..  :)

 

by: chicabowPosted on 2004-04-05 at 07:34:23ID: 10757633

Its not working for me....I tried many different variations, with quote, no quotes....still nothing is working....is there a way to log what happens since we can't actually see the script run?

 

by: Fatal_ExceptionPosted on 2004-04-05 at 08:24:49ID: 10758096

If you are using it in a batch file, test the batch file by itself first...  Add the line 'pause' and it will keep the window open..  

 

by: chicabowPosted on 2004-04-05 at 09:38:45ID: 10758788

I tried that and I got this error
System error 85 has occured
The local device name is already in use.

But it's not in use....so i'm at a loss here...

 

by: Fatal_ExceptionPosted on 2004-04-05 at 09:44:32ID: 10758837

try LPT2  

Let me know

 

by: chicabowPosted on 2004-04-05 at 10:04:33ID: 10759032

Still no go.... :(

 

by: Fatal_ExceptionPosted on 2004-04-05 at 17:35:56ID: 10762180

Here is a MS article on mapping printers with DOS commands..

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q314499

 

by: JamesDSPosted on 2004-04-06 at 02:25:16ID: 10764124

chicabow

you don't need to connect a specific local device (IE an LPT port) to connect a printer

The following VBScript code will connect a printer device without trying to use the LPT ports. The printer device will be available from the printer dialog as a selectable device in any of the print dialogs in windows applications:

Set objWSHNetwork = CreateObject("WScript.Network")  'create network object
strConnectString = "\\server\printer"
strResult = objWSHNetwork.AddWindowsPrinterConnection(strConnectString)

Save it as a .VBS file and change the variable strConnectString to reflect your printer path

Cheers

JamesDS

 

by: steve_newbyPosted on 2004-04-07 at 04:38:36ID: 10773692

James is right with his suggestion, I would definitely avoid using dos batch commands and mapping LPT ports.
If you use his commands in a VB script you can assign this script to a group policy for an OU.  Therefore say you had an OU for each department at your company you would have a different GP on each OU assigning different printers to the users.  This means that if a user moved departments it would be a simple matter of dragging them into the new OU and they would get a different set of printers next time they logged on.

 

by: chicabowPosted on 2004-04-16 at 12:28:54ID: 10845362

Wow that works like a charm JamesDS, well I just created the file and double clicked and it worked....I have not assigned it to the GPOs yet. So need the exact steps of how to attach a vbs to a Group Policy, never used vbs before....
Would also like to enhance this script to remove all instances of printer currently listed then re-add the listed ones. Would like all clients to have a clean list of valid printers.
Please advise.

 

by: Fatal_ExceptionPosted on 2004-04-16 at 12:32:06ID: 10845378

Yea..  those scripts are wonderful.. and I will also be copying it for future reference...  :)

Here is a link to logon scripts that may help you with your GPO's

http://www.tycho7.com/Software/Win2k/logon_scripts.htm

 

by: chicabowPosted on 2004-04-16 at 13:07:15ID: 10845627

I don't see anything about associating with VBS files, I already have each user with a specific bat file, but now I need to add vbs files as well how can this be done using the GPO?

 

by: chicabowPosted on 2004-04-16 at 13:07:45ID: 10845633

And the question about removing the printers..

 

by: Fatal_ExceptionPosted on 2004-04-16 at 13:34:29ID: 10845767

The same way you do your batch files...  Scripts are placed in winnt\sysvol\domain\scripts.  And you use the logon script policy to point your GPO to that script...

 

by: chicabowPosted on 2004-04-16 at 13:46:26ID: 10845850

ok....looking for direction on using (where and how) the logon script policy.

 

by: Fatal_ExceptionPosted on 2004-04-16 at 15:10:01ID: 10846436

The logon script should be placed in the Default Domain Policy GPO.  Also, you should place the policy in the Users section of the GPO where the logon/logoff script policy entries are.  

In fact, here is a link where we discussed this..

http://www.experts-exchange.com/Operating_Systems/Windows_Server_2003/Q_20922065.html

And here is some more help..

http://www.computerperformance.co.uk/w2k3/gp/group_policy_logon_scripts.htm

 

by: Fatal_ExceptionPosted on 2004-04-30 at 12:06:27ID: 10963163

ThankQ

FE

 

by: parksidetimPosted on 2004-05-19 at 09:02:04ID: 11109280

Setting a policy for printer mapping for an OU isn't always what you want to do though. Where I work, in a school, the users have roaming profiles and will log onto many different machines. They will always want to have the nearest printers available to them and other printers throughout the organisation invisible.

The obvious answer would be to assign the policy to an OU containing computers, but, if I put them there (in the Computer startup/shutdown policy) the scripts don't appear to run.
(Anyone any idea why?)

So, I copy the script to the local hard drive and stick a shortcut to it in the startup folder. To ensure that as users move around they don't accumulate printers all over the site the script does the following:
Enumerates all connected printers.
Deletes all connected printers.
Connects only those printers which are nearby.

Works for me, but I'd much rather be able to assign the script to OUs of workstations.

 

by: _HoPPeR_Posted on 2004-05-19 at 22:37:57ID: 11114818

To give my two cents worth.... I use Kix32 in your environment for login script processing.
KIX is a free utility that can be used for many type of scenarios... printers included. Obviously I can't detail them all but here an example of a KIX script I use to automatically add and remove printers based on the user NT group.

This command addes printers if the use belongs to the DEPT_IS nt group

If ingroup("DEPT_IS")

            $ReturnCode = KeyExist("HKEY_CURRENT_USER\Printers\Connections\,,aumelsvr011,AUMELISD1DL")
            If $ReturnCode = 0
               ? "Printer doesn't exist....adding"
                  If addPrinterConnection ("\\aumelsvr011\AUMELISD1DL") = 0
                           ? "Added printer ISD Lexmark T622....AUMELISD1DL"
                  Endif
            Endif
Endif


This command deletes printers if the reg key for the specific printer is found.

$ReturnCode = KeyExist("HKEY_CURRENT_USER\Printers\Connections\,,aumelsvr011,AUMELBOG1DP")
            If $ReturnCode
               ? "Printer doesn't exist....adding"
                  If delPrinterConnection ("\\aumelsvr011\AUMELBOG1DP") = 0
                           ? "Removed printer Business Operations Hewlett Packard 4050....AUMELBOG1DP"
                  Endif
            Endif

I hope this is helpful for some. KIX can be found at www.kixtart.org

Regards

HoPPeR

 

by: trebligbPosted on 2004-07-27 at 14:44:47ID: 11651345

Additionally this code sets an existing printer as the default:

Option Explicit
Dim objPrinter
Set objPrinter = CreateObject("WScript.Network")
objPrinter.SetDefaultPrinter "\\server\printer"
' End of Script


Useful to set the default printer for different groups...

 

by: hoeycPosted on 2004-08-13 at 06:46:57ID: 11792839

I also work in a school. The way I handled the login script problem was to name the computers in an organized fashion that would allow my login script to assign printers based on the name of the computer that the user logs on to. Therefore, if a student logs into computer LAB10, his default printer will be "Printer4". I created a separate script for the teachers, because I don't want students accessing the faulty printers.

-------------------------------------------------------------------------
Dim objNetwork
Dim objPrinters
Dim Printer1, Printer2, Printer3, Printer4

on error resume next

Set objNetwork = CreateObject("WScript.Network")
Set objPrinters = objNetwork.EnumPrinterConnections

objNetwork.AddWindowsPrinterConnection Printer1
objNetwork.AddWindowsPrinterConnection Printer2
objNetwork.AddWindowsPrinterConnection Printer3
objNetwork.AddWindowsPrinterConnection Printer4

Select Case left(objNetwork.ComputerName,3)

      Case "100"
            objNetwork.SetDefaultPrinter Printer1

      Case "200"
            objNetwork.SetDefaultPrinter Printer2

      Case "300"
            objNetwork.SetDefaultPrinter Printer3

      Case "LAB"
            objNetwork.SetDefaultPrinter Printer4      

      Case Else

End Select

-------------------------------------------------------------------

You can also add code to check for a local printer and make that the default in lieu of the closest workgroup printer. This code is much more complicated and I had to account for a terminal server login as well. I hope this helps.

--------------------------------------------------------------------

Set objPrinters = WshNetwork.EnumPrinterConnections

for i=0 to objPrinters.Count-1 Step 2
            
      if Left(objPrinters(i),4)="LPT1" OR Left(objPrinters(i),4)="USB1" Then

            if left(objPrinters(i + 1),3)="Acr" then
                  'don't set acrobat printers as default
            else
                  WshNetwork.SetDefaultPrinter objPrinters(i + 1)
                  defaultPrinter = objPrinters(i+1)
                  defaultPrinterAssigned = true
                  localPrinter=true
            end if

      elseif Left(objPrinters(i),2)="TS" AND DefaultPrinterAssigned = false then
                  PrinterDesc = split(objPrinters(i+1)," ")

                  count = 0
                  for each token in PrinterDesc
                        if token="session" then      
                              sessionnumber = PrinterDesc(count + 1)
                        end if
                        count = count + 1                              
                  next
                  if TermSessionID = sessionnumber then
                        WshNetwork.SetDefaultPrinter objPrinters(i + 1)
                        defaultPrinter = objPrinters(i+1)
                        defaultPrinterAssigned = true
                        TerminalSessionPrinter = true
                  else
                        defaultPrinterAssigned = false
                  end if
      End If

Next


 

by: chumpmastergPosted on 2004-08-21 at 14:27:38ID: 11860819

This works for me in MANY environments.

rundll32 printui.dll,PrintUIEntry /in /n \\%servername%\%printername%

Run this in the run line to get all variables.

rundll32 printui.dll,PrintUIEntry /?

Can you dig?

-chumpmasterg

 

by: BrianpmorisPosted on 2004-11-10 at 08:56:29ID: 12546155

How about connecting to a printer server i.e. jetdirect via an IP port or FQDN? Any Ideas?

 

by: dacombPosted on 2004-12-03 at 19:39:47ID: 12742134

I've got a 300 User network that we are configuring from the ground up and during the first few sites that we made live we noticed that we are going to have to script the printer installs this is going to be far too much work for us to add them to every machine and then readd them when a second user logged into the machine.

I have the same question as Brianpmoris, what about TCP/IP Printer Ports on the clients? Our Client wants 2 mappings for each printer. One for using the windows 2003 print server in the AD (\\server\prt-01) and another map to a local TCP printer port (IP_10.0.0.22).

The reason is if they lost access to the domain / print server they could still print off of the local static mapped ones. First off if anyone has any suggestions on a better way to do this I'm all ears...

Second off I need a script to be able to make this happen. I've read about 10 different ways to map a printer via a script or command line. I really would like to know what the best and easiest way to make this happen is. All of my servers are Server 2003 and all of the workstations are Windows XP Pro.






 

by: Fatal_ExceptionPosted on 2004-12-03 at 20:08:46ID: 12742191

dacomb...  you need to ask your question in a new thread if you really want to attract attention to your question...  You might even want to place it in the scripting section too, along with in the W2K3 section..

FE

 

by: RLUNTPosted on 2005-01-11 at 06:46:59ID: 13014064

Check out this site: http://www.robvanderwoude.com/index.html - search for command line printer control

I wrote the following batch file based on info found at this site and others to do exactly what you want to do.

There are commands to map to a particular port -either local or by IP - see above site

@ECHO OFF
rem VER | FIND "Windows 2000" >NUL
rem IF ERRORLEVEL 1 GOTO Not2000

SETLOCAL

SET Printer=%1


:: Check printer specified
IF NOT DEFINED Printer GOTO NoPrinter
IF NOT "%Printer:~0,2%"=="\\" GOTO MissingBS
FOR /F "tokens=1* delims=\" %%A IN ('ECHO.%Printer%') DO (
      SET PrintServer=%%A
      Set PrintShare=%%B
)

rem echo "Line 12"

IF NOT DEFINED PrintShare GOTO NotDefinedShare
PING %PrintServer% -n 1 -w 1000 2>&1 | FIND "TTL=" >NUL
IF ERRORLEVEL 1 GOTO Syntax
NET VIEW \\%PrintServer% 2>&1 | FIND /I "%PrintShare%" >NUL
IF ERRORLEVEL 1 GOTO Syntax

rem echo "Line 30"


rem echo "Line 40"

:: Install the printer on the specified computer
echo
ECHO About to INstall the Printer: %Printer%
echo
rem Most of this was taken from http://www.robvanderwoude.com/index.html - Command Line Printer Control
rem This line give the printers property
RUNDLL32 PRINTUI.DLL,PrintUIEntry /p /n\\machine\printer

rem
rem If ths property of the printer is available then it is installed already so don't re-add
rem This line deletes printers - gd
rem RUNDLL32.EXE PRINTUI.DLL, PrintUIEntry /gd /n%Printer% %RemotePC%
rem
rem This line ADDs printers - ga
IF NOT ERRORLEVEL 1 RUNDLL32.EXE PRINTUI.DLL, PrintUIEntry /ga /n%Printer% %RemotePC%


net stop spooler
net start spooler
IF NOT ERRORLEVEL 1 ECHO Printer: %printer% installed

ENDLOCAL
GOTO:EOF

:NOPrinter
echo
echo Error - Printer not defined: %Printer%
echo
goto Syntax


:MissingBS
echo
echo Error - Missing BackSlashes : %Printer%
echo
goto Syntax

:NotDefinedShare
echo
echo Error - NotDefinedShare : %Printer%
echo
goto Syntax

:Not2000
echo
echo Error - Not 2000 or XP
echo VER | FIND "Windows 2000" >NUL
echo
goto Syntax

:Syntax
ECHO.
ECHO AddPrint.bat,  Version 1.00 for Windows 2000
ECHO Install a network printer on any PC on the network
ECHO.
ECHO Usage:  ADDPRINT  \\print_server\printer_share
ECHO.
ECHO Where:              "print_server"   is the print server name or IP address
ECHO                     "printer_share"  is the share name for the printer

ECHO.
ECHO Written by Rob van der Woude
ECHO http://www.robvanderwoude.com

IF "%OS%"=="Windows_NT" ENDLOCAL

 

by: Sune_StevnsborgPosted on 2005-04-09 at 09:59:12ID: 13744196

I use VBscripting for mapping printers.
I have the same problem as you have, the users needs a list of printers to select from.
VBScript lacks forms, this can be fixed by using wshDialog (GNU general public license, version 2).
First the list is shown for the selection of a default printer and the aging for selection for additional printers.
You need to change the domain name for the SQL statement (The domain is “domain.local” right know). All printer need to be listed in the AD.
The script follows:

Option Explicit

Const vbModal = 1
Const ADS_SCOPE_SUBTREE = 2

Dim oDlg, oReplicatorForm, oPrinterForm, sBtn, objConnection, objCommand, objRecordSet, x, i, oNet, oShell, oPrinters

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = "SELECT printerName,serverName,location,UncName FROM " _    
    & " 'LDAP://DC=domain,DC=local'  WHERE objectClass='printQueue' ORDER BY printerName"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 30
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results") = True
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

x=1
i=0
Set oNet = CreateObject("WScript.Network")
Set oShell = WScript.CreateObject("WScript.Shell")

Set oDlg = Wscript.CreateObject("WshDialog.Kit")
Set oReplicatorForm = BuildReplicatorForm(objRecordSet)
objRecordSet.MoveFirst
Set oPrinterForm = BuildPrinterForm(objRecordSet)
objRecordSet.MoveFirst

oReplicatorForm.Show vbModal

Select Case Ucase(oDlg.Clicked)
Case "1"
    sBtn = oReplicatorForm.GetOptionButton("FRM1")

      If oReplicatorForm.Ctl("Remove").Value Then
            Set oPrinters = oNet.EnumPrinterConnections
            For i = 1 to oPrinters.Count - 1 Step 2
                     If Left(oPrinters.Item(i),2)="\\" Then
                           oNet.RemovePrinterConnection oPrinters.Item(i)
                     End If
            Next
      End If
      
      oNet.AddWindowsPrinterConnection sBtn
      oNet.SetDefaultPrinter sBtn
      
      oPrinterForm.Show vbModal
      
      Select Case Ucase(oDlg.Clicked)
      Case "3"
          Do while x=<objRecordSet.RecordCount
                If oPrinterForm.Ctl("Box"&x).Value Then
                      oNet.AddWindowsPrinterConnection objRecordSet.Fields("UncName").Value
                      objRecordSet.MoveNext
                End If
                x=x+1
          Loop
          MsgBox "Printer installationen er ferdigt"
      Case Else
          MsgBox "Du har kun installeret en default printer"
      End Select

Case Else
    MsgBox "Du har annulleret instalationen du har ikke adgang til printerene"
End Select

oReplicatorForm.Clear
oPrinterForm.Clear
Wscript.DisconnectObject oDlg
Set oDlg = Nothing


Function BuildReplicatorForm(objRecordSet1)

    Dim oFrm1, BtnPlaceHigh, BtnPlaceLeft, Rows, oCtl, x

    Set oFrm1 = oDlg.NewForm
      BtnPlaceHigh=300
      BtnPlaceLeft=150
      Rows=(objRecordSet1.RecordCount-(objRecordSet1.RecordCount mod 15))/15+1
      x=0


    oFrm1.NewButton "1", 450, 7600, 750, 375, "&Next"
    oFrm1.NewButton "Cancel", 1400, 7600, 750, 375, "&Cancel"
    oFrm1.Ctl("Cancel").Cancel = True

      Set oCtl = oFrm1.NewCheckBox("Remove", 450, 7100, 1800, 375, "Remove old printers",1, "FRM1")
      oCtl.ToolTipText = "Fjern gamle printere"

    oFrm1.NewImage "IMG1", 250, 200 , 0, 0, "IconQuestion"
    oFrm1.NewLabel "LBL1", 1150, 300, 3000, 375, "Printer valg"
    oFrm1.NewFrame "FRM1", 400, 700, Rows*4500, 6300, " Vælg Default Printer "
      Set oCtl = oFrm1.NewLabel("LBL2", (Rows*4500)-1450, 7500, 1800, 200, "By Sune Stevnsborg")
      oCtl.ForeColor = RGB(66, 66, 66)
      Set oCtl = oFrm1.NewLabel("LBL3", (Rows*4500)-1450, 7710, 1800, 200, "For Leif Hansen Gruppen")
    oCtl.ForeColor = RGB(66,66, 66)
    Do Until objRecordSet1.EOF
      Set oCtl = oFrm1.NewOptionButton(objRecordSet1.Fields("UncName").Value, BtnPlaceLeft, BtnPlaceHigh, 4300, 375, objRecordSet1.Fields("printerName").Value,False, "FRM1")
      oCtl.ToolTipText = "Vælg Default Printer"
    objRecordSet1.MoveNext
      BtnPlaceHigh=BtnPlaceHigh+400
      x=x+1
      If x=15      Then
            BtnPlaceLeft=BtnPlaceLeft+4350
            BtnPlaceHigh=300
            X=0
      End If
    Loop
    oFrm1.Caption = "Printer Installation"
    oFrm1.TaskBar = False
    oFrm1.AutoSize
    Set BuildReplicatorForm = oFrm1
End Function


Function BuildPrinterForm(objRecordSet2)

    Dim oFrm2, BtnNr, BtnPlaceHigh, BtnPlaceLeft, Rows, oCtl, x

    Set oFrm2 = oDlg.NewForm("2")
      BtnNr=1
      BtnPlaceHigh=300
      BtnPlaceLeft=150
      Rows=(objRecordSet2.RecordCount-(objRecordSet2.RecordCount mod 15))/15+1
      x=0

    oFrm2.NewButton "3", 450, 7100, 750, 375, "&Done"
    oFrm2.NewButton "Cancel", 1400, 7100, 750, 375, "&Cancel"
    oFrm2.Ctl("Cancel").Cancel = True

    oFrm2.NewImage "IMG1", 250, 200 , 0, 0, "IconQuestion"
    oFrm2.NewLabel "LBL1", 1150, 300, 3000, 375, "Printer valg"
    oFrm2.NewFrame "FRM2", 400, 700, Rows*4500, 6300, " Vælg yderlgere printere "
      Set oCtl = oFrm2.NewLabel("LBL2", (Rows*4500)-1450, 7100, 1800, 200, "By Sune Stevnsborg")
      oCtl.ForeColor = RGB(66, 66, 66)
      Set oCtl = oFrm2.NewLabel("LBL3", (Rows*4500)-1450, 7310, 1800, 200, "For Leif Hansen Gruppen")
    oCtl.ForeColor = RGB(66,66, 66)
   

    Do Until objRecordSet2.EOF
      Set oCtl = oFrm2.NewCheckBox("Box"&BtnNr, BtnPlaceLeft, BtnPlaceHigh, 4300, 375, objRecordSet2.Fields("printerName").Value,, "FRM2")
      oCtl.ToolTipText = "Vælg yderlgere printere"
         objRecordSet2.MoveNext
         BtnNr=BtnNr+1
      BtnPlaceHigh=BtnPlaceHigh+400
      x=x+1
      If x=15      Then
            BtnPlaceLeft=BtnPlaceLeft+4350
            BtnPlaceHigh=300
            X=0
      End If
    Loop

    oFrm2.Caption = "Printer Installation"
    oFrm2.TaskBar = False
    oFrm2.AutoSize
    Set BuildPrinterForm = oFrm2
End Function

 

by: BrianpmorisPosted on 2005-08-11 at 03:44:29ID: 14650215

I am no script kiddy so please don’t flame me for my appalling script. On windows XP there are built in vbs scripts that will allow you to create IP printer ports and manage printer objects.

cscript c:\windows\system32\prnport.vbs -a -o raw -r IP_192.168.0.10 -h 192.168.0.10
cscript c:\windows\system32\prnmngr.vbs -a -p "HPLJ2300" -m "HP Laserjet 2300 Series PCL 5e" -r "IP_192.168.0.10"

I placed both of the above lines in a bacth file and it did the job just fine. I am sure a better script can be created as my coding skills are very lame.

 

by: RLUNTPosted on 2005-08-11 at 05:42:14ID: 14650840

Here is a simpler solution I found on the web recently

I created a script and launched it from the login script (login.bat)

Dim net
Set net = CreateObject("WScript.Network")
net.AddWindowsPrinterConnection "\\dbsinhouse3\Canon3100FAX"
net.AddWindowsPrinterConnection "\\dbsinhouse3\Canon3100PCL"
net.AddWindowsPrinterConnection "\\dbsinhouse3\CanoniRC"
net.AddWindowsPrinterConnection "\\dbsinhouse3\LexmarkO"
net.AddWindowsPrinterConnection "\\dbsinhouse3\Tek850"

Work wonderful and is so simple.

 

by: chicabowPosted on 2005-08-11 at 14:50:32ID: 14656351

That looks good, is there one for Network Places as well?
I have a bunch of network places I want added is there a script for it?

 

by: RLUNTPosted on 2005-08-29 at 06:19:58ID: 14775687

Can you explain network places? I don't understand the question you presented.
Thanks

 

by: MadmanDKPosted on 2005-10-17 at 06:24:12ID: 15099104

I use con2prt, it is easy to use, but i need to connect printers to computers.

eks. all computers in room A shoud have printer A as default printer, i have uset logon script, it does not work.

This connect all printers, but Xerox will always be default.
\\Bilbo\NETLOGON\con2prt /c \\bilbo\Xerox
\\Bilbo\NETLOGON\con2prt /c \\bilbo\EDB1
\\Bilbo\NETLOGON\con2prt /c \\bilbo\Lille-M
\\Bilbo\NETLOGON\con2prt /c \\bilbo\SOL
\\Bilbo\NETLOGON\con2prt /c \\bilbo\Mediatek

Any ide?

 

by: xuserx2000Posted on 2008-04-26 at 22:26:07ID: 21448258

I prefer the IFMEMBER method...once setup properly...it's easy to manage through AD which printers a user is assigned.
http://www.microsoft.com/technet/archive/winntas/tips/winntmag/grlogon.mspx?mfr=true
First make all of your printers shared on a print server...

Example logon script.....too easy.

ifmember "accounting users"
if not errorlevel 1 goto EXIT
cscript prnmngr.vbs -x
cscript prnmngr.vbs -ac -p "\\servname\printersharename"
:EXIT

i just deleted all printers and added \servername\printer provided the user is a member of "accounting users".

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...