opshn
2006-10-23 19:11:13 UTC
I have many computers here at work that varies from win2k to win XP and
I need to run a net use command every time the computers boot up.
The command is:
net use lpt1: \\pcname\printername /persistent:yes
The pcname is the name of the pc that the command runs on. So I could
use %computername% for that.
The printername is where I have my first problem. I want this to be
whatever the default printer is for the pc. Something like:
cscript prnmngr.vbs -g
Which I have tried outputting to a file and then trying to get my
printer name out of the file with a FIND command. Unsuccessfully.
The second issue is that each computer will be logged in as a user with
restricted access and I believe that the net use command needs to be
run by the local administrator. Which if I put this batch file in the
startup folder then it would not run as the administrator. I have found
some examples of passing a user name and password but I would rather
not do that in a batch file that any user could read.
In short I want two things:
1. The default printer name stored to a variable to use on a net use
command.
2. My batch file to run as administrator but without someone being able
to figure out what the password is.
I need to run a net use command every time the computers boot up.
The command is:
net use lpt1: \\pcname\printername /persistent:yes
The pcname is the name of the pc that the command runs on. So I could
use %computername% for that.
The printername is where I have my first problem. I want this to be
whatever the default printer is for the pc. Something like:
cscript prnmngr.vbs -g
Which I have tried outputting to a file and then trying to get my
printer name out of the file with a FIND command. Unsuccessfully.
The second issue is that each computer will be logged in as a user with
restricted access and I believe that the net use command needs to be
run by the local administrator. Which if I put this batch file in the
startup folder then it would not run as the administrator. I have found
some examples of passing a user name and password but I would rather
not do that in a batch file that any user could read.
In short I want two things:
1. The default printer name stored to a variable to use on a net use
command.
2. My batch file to run as administrator but without someone being able
to figure out what the password is.