Computing.Net > Forums > Programming > XP Command Line

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

XP Command Line

Reply to Message Icon

Name: steigrafx
Date: May 10, 2006 at 12:36:13 Pacific
OS: XP Home
CPU/Ram: P4 2.4GHz/512MB
Comment:

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: /delete

Thanks for your help.



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: May 11, 2006 at 05:23:48 Pacific
Reply:

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



0

Response Number 2
Name: steigrafx
Date: May 11, 2006 at 05:58:12 Pacific
Reply:

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


0

Response Number 3
Name: Mechanix2Go
Date: May 11, 2006 at 06:39:24 Pacific
Reply:

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



0

Response Number 4
Name: steigrafx
Date: May 11, 2006 at 07:03:30 Pacific
Reply:

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%.bat

There 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


0

Response Number 5
Name: IVO
Date: May 11, 2006 at 07:19:09 Pacific
Reply:

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.


0

Related Posts

See More



Response Number 6
Name: steigrafx
Date: May 11, 2006 at 07:44:49 Pacific
Reply:

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


0

Response Number 7
Name: Mechanix2Go
Date: May 11, 2006 at 08:45:19 Pacific
Reply:

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



0

Response Number 8
Name: IVO
Date: May 11, 2006 at 12:41:31 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

DOS Batch Line Currency Formatting Javas...



Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: XP Command Line

Date Variable in XP Command Line FTP www.computing.net/answers/programming/date-variable-in-xp-command-line-ftp/19183.html

kill a process from command line www.computing.net/answers/programming/kill-a-process-from-command-line/14109.html

What happened to Command Line Help? www.computing.net/answers/programming/what-happened-to-command-line-help/19425.html