Spot Posted September 9, 2005 Posted September 9, 2005 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.
Geoff Posted September 9, 2005 Posted September 9, 2005 Is the script trying to access information that doesn't exist? eg, logged in user info?
Spot Posted September 9, 2005 Author Posted September 9, 2005 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
Geoff Posted September 9, 2005 Posted September 9, 2005 Network printers are per user settings. You can't add them at machine start up. Run the script at user login instead.
Spot Posted September 9, 2005 Author Posted September 9, 2005 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?
Geoff Posted September 9, 2005 Posted September 9, 2005 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.
StewartKnight Posted September 10, 2005 Posted September 10, 2005 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!
Geoff Posted September 10, 2005 Posted September 10, 2005 That script will run at login though Stewart.
Ric_ Posted September 10, 2005 Posted September 10, 2005 With Geoff there Stewart - I've always used my scripts at login through a GPO.
StewartKnight Posted September 10, 2005 Posted September 10, 2005 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!
MkII Posted September 10, 2005 Posted September 10, 2005 Stewart - the thrust of the thread authors question is for a machine startup script, not a user logon script.
StewartKnight Posted September 10, 2005 Posted September 10, 2005 I think you're getting a little picky there! All this poor chap want to do is get his printers to work. I'm sure he doesn't care if it's when the machine boots, or the user logs on!
MkII Posted September 10, 2005 Posted September 10, 2005 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.
Spot Posted September 11, 2005 Author Posted September 11, 2005 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...
StewartKnight Posted September 12, 2005 Posted September 12, 2005 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"
Mango_RW Posted September 16, 2005 Posted September 16, 2005 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"
secman Posted November 15, 2005 Posted November 15, 2005 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
MkII Posted November 15, 2005 Posted November 15, 2005 Thanks secman. What O/S's have you tried that on/do you have that working on?
secman Posted November 16, 2005 Posted November 16, 2005 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now