Finding printers from a command prompt

 
Thread Tools Search this Thread
Special Forums Windows & DOS: Issues & Discussions Finding printers from a command prompt
# 1  
Old 02-26-2006
Finding printers from a command prompt

Does anyone know how I can find printers from a dos prompt?

I'm trying to create a batch file which cats the printers and
their locations to another file which I will use later in the
script.

Maybe windows has a file from which I may read in this
information?

Thanks!
# 2  
Old 03-28-2006
Very clunky, but:

for /f %i in ('net view') do net view %i | find "Print" >>result.txt

Explanation:
'net view' - command to display all sharing-enabled computers in a workgroup or domain.
'for /f %i ...' - for each line of result (%i) from 'net view', list the shares on that computer.
'| find "Print" - Pipe the preceding output through FIND.COM and look for the string "Print", indcating a shared printer.
'>>result.txt' - append the output to the file "result.txt", NOTE: >> to append, not > to write to or we'll only see the last positive match in our file.

The resulting file (result.txt in this case) will look something like:
[Netbios name, Service, Comment]

AC_PRN Print Accounts department multifunction

PR_DESJ Print Public Relations department Colour Deskjet

SH_DMP Print Shipping office dot-matrix label printer

Hope it helps.

If you want anything better I think you're going to have to look at some VB scripting and active directory-based looking-up.

Last edited by jallport; 03-28-2006 at 08:29 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Shell script not working but command works in command prompt

Hi everyone I have a problem with my script If I try directly this command /usr/bin/nice -n 19 mysqldump -u root --password="******" wiki_schneider -c | nice -n 19 gzip -9 > /point_de_montage/$(date '+%Y%m%d')-wiki-db.sql.gz It works But if I simply add this command in a script and... (8 Replies)
Discussion started by: picemma
8 Replies

2. Shell Programming and Scripting

Command prompt

Hi All, Even changing .bash_profile, i am getting only $ as command prompt. My bash profile looks like this. PS1=" $ " stty columns 200 set -o vi if i run bash command and run PS1=" $ " then it is working as expected. $ bash (4 Replies)
Discussion started by: akshu.agni
4 Replies

3. SCO

Booting to Command Prompt

Hello, I need help booting to a command prompt. The server runs SCO Openserver 5.0, with a point of sale program that automatically boots upon startup. I can't gain root access, and the administrator password for the point of sale program is un-obtainable. I am upgrading to a new point of sale... (8 Replies)
Discussion started by: tedcurvin
8 Replies

4. UNIX for Dummies Questions & Answers

Execution of command at command prompt

Hello Experts, I am still learning linux and have come across a question, hope to get some answer. I have two servers, and both have the same version of svn client installed and both have the same user_id. my SVN client version: svn, version 1.6.11 (r934486) compiled Mar 2 2011,... (4 Replies)
Discussion started by: babyPen1985
4 Replies

5. UNIX for Advanced & Expert Users

autosys command(autorep) from command prompt

Hi, I am using AUTOSYS GUI based tool. But I want to get the job status from the UNIX command prompt. 1. I want to execute only autorep command in the UNIX command prompt. If need to execute this command what are the settings need to do that. 2. Is it possible for executing this... (5 Replies)
Discussion started by: onesuri
5 Replies

6. UNIX for Dummies Questions & Answers

What does $ represent in command prompt?

What does $ represent in command prompt? (2 Replies)
Discussion started by: ashok.g
2 Replies

7. Windows & DOS: Issues & Discussions

Command Prompt

Hi does anyone know know how to find out the password on a vista pc using command prompt /cmd not change it (1 Reply)
Discussion started by: popo123456789
1 Replies

8. SuSE

inconsistent ls command display at the command prompt & running as a cron job

Sir, I using the following commands in a file (part of a bigger script): #!/bin/bash cd /opt/oracle/bin ls -lt | tail -1 | awk '{print $6}' >> /tmp/ramb.out If I run this from the command prompt the result is: 2007-05-16 if I run it as a cron job then... (5 Replies)
Discussion started by: rajranibl
5 Replies

9. Windows & DOS: Issues & Discussions

Display Printers via command line

Is there an easy way to view all printers on a local machine via command line or a script? I'm looking for the equivalent of clicking on "START, CONTROL PANEL, PRINTERS AND FAXES" to view the devices. I then want to cat it to a file where I would use it later. Thanks (3 Replies)
Discussion started by: gseyforth
3 Replies

10. Shell Programming and Scripting

Command prompt from within a script?

I am writing a menu script and one of the options is to access a Command Prompt and return to the menu via CTRL-D. I have tried using a loop and echoing the PS1 value, then using read to assign whatever is entered into a variable, then executing the value of that variable as a command using .... (1 Reply)
Discussion started by: sanitywonko
1 Replies
Login or Register to Ask a Question