Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have a batch file that I am trying to automatically populate with machine name, shared printer name, and user name (under WinXP Pro). I can't for the life of me figure out how it can be done. Here is my batch file which, for now, I must populate manually for every user:
net use lpt1: /delete
net use lpt1: \\MachineName\SharedPrinterName
call u:\dbmaster\batch_~1\UserName.bat
net use lpt1: /deleteThanks for your help.

How about:
::== my.bat
net use lpt1: /delete
net use lpt1: \\%COMPUTERNAME%\SharedPrinterName
call u:\dbmaster\batch_~1\%UserName%.bat
net use lpt1: /delete
:: DONE
=====================================
If at first you don't succeed, you're about average.M2

Thank you, that populated the computer name perfectly. Do you know if there's a similar way to populate the shared printer name and user name, as well?
Thanks again,
Kevin

Hi Kevin,
I don't have a network or a printer. LOL
Go to a commanf prompt and:
set
see if the is a variable set to the printer name.
=====================================
If at first you don't succeed, you're about average.M2

Thanks again for your help. I was able to populate the name for the called batch file by using the Netware User Name -- that worked great. That's two out of three.
net use lpt1: \\%computername%\%printsharename%
call u:\dbmaster\batch_~1\%nwusername%.batThere was nothing in Set for the shared printer name, but I did find printsharename in the registry and, as you can see, I tried it but it didn't work. Once I get over that last hurdle, I'll have a generic batch file that I won't need to hand edit for every user.
Thanks again for your help.
Kevin

If you have the Registry ommand you can display the key storing the sharedprintername and then parse the result to set up a variable. See
http://www.mkssoftware.com/docs/man1/registry.1.asp
If you report *exactly* the screen
you get from the key, I or M2Go can do the job for you.

Thanks, IVO, for your input. But I just realized that there is an extremely simple solution -- I'll name every shared printer with the same name put it directly into the batch file. Problem solved!
Thanks again, Mechanix2Go and IVO.
Kevin

Hi IVO,
I don't have REGISTRY; is it part of reskit or something?
Hi Kevin,
good job
=====================================
If at first you don't succeed, you're about average.M2

Hi Mechanix2Go,
forget Registry that is part of a commercial package (MKS Toolkit) and take a look at REG, the standard command line utility to query and manipulate registry keys in Win 2K/XP.
I'm sure you enjoy this highly dangerous toy, a true nuke in expert batcher's hands!
Ciao
IVO

![]() |
DOS Batch Line
|
Currency Formatting Javas...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |