Link to home
Start Free TrialLog in
Avatar of Phipps-IT
Phipps-ITFlag for United States of America

asked on

Logon Batch Script

Experts,

I have deployed logon scripts in my environment under the user configuration. The batch code is:

@ech off

start /high \\printserver\printername

The script does the job at the logon but a message pops up stating Before you can use the printer \\path, it must be set up on your computer. Do you want windows to set up the printer and continue this operation?

How can I eliminate this message? Is there a code that can be added so it would connect the user to the printer without prompting?


Avatar of InteractiveMind
InteractiveMind
Flag of United Kingdom of Great Britain and Northern Ireland image

> Do you want windows to set up the printer and continue this operation?

I'm guessing that you can bypass this, by typing in either "Y" or "N", correct? If so, then you can resort to a pipe to bypass the message, like so:

   @echo off
   echo y| start /high \\printserver\printername


Good luck.
Hm..
>> but a message pops up

Would I then be correct to say that this message is in a new window? (As opposed to the message being outputted to the Command Line window).

If so, firstly try passing a 'y' parameter to the command, like so:

   @echo off
   start /high \\printserver\printername /y

If no luck, then you'll probably need to resort to some external scripting (probably achievable in VB).
Avatar of Phipps-IT

ASKER

Ok,

l tested it with the y but it didn't work,

Is the character after y a pipe?
Avatar of techiesue83
techiesue83

I think the "/y" should actually be a "<y".  It's been a while, but I'm pretty sure it is not a slash...  May be a pipe as well.
I ran it through the command prompt but I got the prompt again. what does Y stands for?
> Is the character after y a pipe?
Yes.

> I think the "/y" should actually be a "<y".  
This is incorrect -- the '<' character is an input-redirection operand, which is used to input multiple strings to a command (whereas you're limited to only one command when using the pipe).

I'll have a think, and see if I can think up an alternative..
> what does Y stands for?
By using the "Y", we're attempting to bypass the prompt (as most prompts require either a "Y" (for "Yes") or "N"..); whichever one suits your situation best.
I ran:

start /high \\printserver\printername "<y" and "y" but still get the prompt
Try using the solution recommended by InteractiveMind but put a space between the "y" and the pipe symbol:

 echo y | start /high \\printserver\printername
> Try using the solution recommended by InteractiveMind but put a space between the "y" and the pipe symbol:
Feel free to try it, but I'm confident that this won't make a difference; they will both do the same thing. Also, we've already established that due to the popup message being a window (other than a Command Line message), an echo redirection would not take effect on it.
Strangely the echo Y | start /high \\printserver\printername did the job on my machine which is XP but it prompts on the test machine that is running 2000 Pro.???????????
!?! Really !?!

How very odd! lol
>>start /high \\printserver\printername <<

Using the "start" command initiates a new window in which to run the command... I don't think you can pipe data into that new window.  On my system when I issue that statement (with my values for printserver\printername) I get a gui window that displays the printer queue.  I don't get the message you see but, then, the printer I'm using is already setup and is the default on my workstations.

What, specifically, are you trying to achieve by placing this command in your logon script?  There may be another acceptable way to accomplish it.

HTH,
Lynn
We have Over 200 computers and many different organizations. each OU has its own printer. Users in each OU needs to be connected to their own network printers. We don't want them to see the prompt. We need to deploy a GPO to install the printer at the logon with out taking their attention
I just tested it again. It works on winXP but not on 2000???
I'm sure that this won't work, but just so that we can 100% rule it out, try this quickly:

   start /high \\printserver\printername & echo y
Once the printer is set up on each users station, does the prompt still occur?  If not, it might be just as easy to notify your users what to expect and to respond to the prompt in the affirmative when they get it.  Not necessarily the prettiest solution, but may keep you from pulling your hair out.  

On the other hand, if the prompt always appears, that won't help.

One thing I have done is to customize logon scripts for departments. Assuming that your users are categorized in groups by department.  You can then test the userid and use the appropriate print server for that department at logon.  That can be done by if-then-else statements in the logon script or by using different scripts for each dept.
 
I noticed in your first post that you misspelled echo:




Experts,

I have deployed logon scripts in my environment under the user configuration. The batch code is:

@ech off

start /high \\printserver\printername

The script does the job at the logon but a message pops up stating Before you can use the printer \\path, it must be set up on your computer. Do you want windows to set up the printer and continue this operation?

How can I eliminate this message? Is there a code that can be added so it would connect the user to the printer without prompting
No,

it did not work, however I found a program called adprintx. I deployed it along with a script:
@echo off
adprintx  /cd "\\printserver\printername"

it worked for me.
Preece,

the @echo off command, only prevents command echos'; the only effect it would have, is output-related (as opposed to the performance/processes).
It was just an observation!  ; - )  
Thats correct,

Fair enough  ^_~
I am sorry I don't undrestand what you mean with observation
ASKER CERTIFIED SOLUTION
Avatar of InteractiveMind
InteractiveMind
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
My knowledge with programming is very little. Thank you all the info you provided me.

Bobby
Thank you very much, Bobby.  :-)