Jump to content

Recommended Posts

Posted

Forgive my ignorance on this one. Trying to get a vb script to run on computer startup to attach printers.

 

I've added the script to the Startup Scripts under Computer Configuration\Windows Settings\Scripts and assigned the gpo to a test ou with one pc in for testing.

 

When logging on the machine says it is processing scripts, but the printer info does not get set.

 

Once logged on, I can run the script as a student user and the printer script works fine - slight issue of students having to agree to open a vbs file though...

 

I've copied the "physical" script file itself to the policies' "Machine\Script\Start Up" folder too.

Posted

Hi Geoff

 

It's just getting the computer name and connecting to a network printer. It's based on the vb script discussed in another forum here ("Setting a permanent default printer"). I've just deleted the stuff not applicable to us and changed the rooms / printer info.

 

I started getting a little desparate so have started sticking 'msgbox' statements in to test the select case stuff. It seems to pick up the room info ok and goes to the correct section to add the printer - just doesn't add the chuffing printer!

 

I've enclosed the script to for anyones' perusal - note extension changed to ".txt". Again - work in progress and the msgbox statements throughout are deliberate - to be removed when the darn thing works!

 

Just checked the security permissions on the server printer share - Everyone has 'Print' access. Shouldn't need any more than that should it?

 

All suggestions gratefully received!

printers2.txt

Posted

Ta very much Geoff - I'll try with a user on Monday.

 

Is there a way I can attach printers at machine startup instead of at user logon?

Posted
You can setup a network printer as a local printer if you set the printer port to TCP/IP (assuming you have printers that support that). I've no idea how to script that though. Works ok thru the add printer wizard though.
Posted
Sorry Geoff, but I beg to differ! In documents & Settings, all users, start menu, programs, startup, add the script. Thats how I've done it. If you still have problems post again, and I'll send you my script, which is currently working on 100 computers & 50 laptops!
Posted
Geoff says that you have to set up a tcp/ip printer port. What I'm saying is, you don't have to. Share the printers on the server, then use the script to attach the printers to the local machine. This method means you have only 4 small lines of code, and it does'nt take a second to run, No drivers to install, and if you change the printer, as long as you give it the same share name, the printer is instantly available for the users!
Posted

Well yes I agree, it works at logon so why bother doing it at machine startup - but that's the question.

 

As a matter of fact i'm having the same problem with my old script that has always worked previously - don't know if a GPO setting has blocked it, but i've run the script visibly, put pauses in it, and it all seems to execute properly, but as Spot is saying - the frelling printers don't get attached!

 

I've just re-imaged too, and migrated to 2003 server - migrating to a new box, leaving the old box as print server.

The script is run when the user has logged in, but as I said, running the script visible it seems to be running fine without errors. There is a GPO setting to force the script to run before the user logs in as I recall, which previously wouldn't work for me from my 2000 server - maybe try that Spot.

Posted

Ta very much for all the suggestions. I'll be doing more testing on Monday.

 

I'm not really to fussed which way it works - as long as it works!

 

Another one to chuck into the pot - for some reason I have one shared printer that refuses to go away. I need to have more of a look at but, briefly, this is the story so far...

 

Created a RIS image for a new Dell PC. Edited the .sif file to include a printer. Applied the RIS image to a pile of new PCs. Set up a new default user profile on one of the newly "rissed" PCs. Any computers this user profile logs on to include the printer from the newly "rissed" PCs.

 

I'm sure I've tried deleting this printer in a logon script, but it still seems to be there!

 

I still need to investigate this further - hopefully should get a fix tomorrow and let you all know.

 

Once again thanks for the suggestions so far - I was running out of walls to bang my head against...

Posted

for what it's worth, this is my logon script:

 

Dim oNetwork, sPrintPath

Set oNetwork = CreateObject("WScript.Network")

 

sPrintPath ="\\10.102.28.7\Room16"

oNetwork.AddWindowsPrinterConnection sPrintPath

oNetwork.SetDefaultPrinter sPrintPath

 

 

WScript.Quit

 

 

you can take out the SetDefaultPrinter for the 2nd printer

 

the printer server is 10.102.28.7, and the printer name is shared as "Room16"

Posted

Another thing to consider here is a sleep timer, we had problems where the machine was so quick at installing the printer it exited the script before the setdefault action was completed.

 

Our script:

 

rem ** Next line must not be deleted **

SleepTime=15

Set WshNetwork = CreateObject("WScript.Network")

 

rem ** This will delete existing printers **

On Error Resume Next

Set oPrinters = WshNetwork.EnumPrinterConnections

For i = 1 to oPrinters.Count - 1 Step 2

WshNetwork.RemovePrinterConnection oPrinters.Item(i)

Next

 

WshNetwork.AddWindowsPrinterConnection "\\\StaffRoom-Laser"

 

rem ** Set Default Printer **

WScript.Sleep SleepTime*1000

WshNetwork.SetDefaultPrinter "\\\StaffRoom-Laser"

  • 1 month later...
Posted

Just come across this thread.

Unfortunately we do not have much in the way of VB Scripting skills here. Not for the want of trying. However we have found a way of setting default printers on each machine in a room. We have 6 computer suites all with their own printers, therefore we need to assign printers to 30ish PCs at a time. I have put together batch files run from a server that connect to the admin share on the PC and add a printer using the following (sample)

>RUNDLL32 PRINTUI.DLL,PrintUIEntry /ga /c\\%1 /n\\PRINT01\HPLJrm35

>IF NOT ERRORLEVEL 1 ECHO Printer HPLJrm35 installed on %1 >>printlog.txt

start /wait sc \\%1 stop spooler

start /wait sc \\%1 start spooler

 

%1 is the PC name e.g PC_3501, HPLJRm35 is the printer name.

 

This is run on all or one of the PCs in a room. We do also have rooms with two printers and simply add the second printer as another line.

 

When the user logs on "Printer.BAT" is run from the PC C:drive. to set the default printer (especially when there is more than 1 printer in a room)

 

This is as follows:

@echo off

@break off

Rem ...and make it the default

rundll32 printui.dll,PrintUIEntry /y /q /n\\PRINT01\HPLJRm35

start /wait sc \\%1 stop spooler

start /wait sc \\%1 start spooler

 

Hope this might be useful

Posted
Thanks secman. What O/S's have you tried that on/do you have that working on?

 

It works on XP, with or without SP2 using W2K print server.

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



×
×
  • Create New...