Batch File Help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am not sure if I have posted this in the correct area so sorry if that is
the case.

I am trying to devise a generic batch file to map a network drive to any PC.
The way I am trying to get it to work is using something along these lines;

net use * \\computer_name\c$ /u:login

Ideally I want the batch file to run the net use command and then prompt me
for the computer name which i would type in, and then prompt me for the
password of the local login account which again i would type in.

I have tried the following but it only maps a drive to my local PC [which
you would expect]

net use \\%computer_name%\c$ /user:login

I recall using one a few years ago on NT but cannot recall how it worked and
the person who devised it has since left the company.

Is this sort of command still possible? I only ask because I have to map to
a load of PCs to troubleshoot something and I want to try and automate it.

Any help is appreciated, many thanks in advance.

Paul
 
Hi,

Try this one:

--------------------8<----------------------
@echo off
setlocal

set /p comp=Enter computer name name:
net.exe use * \\%comp%\c$ * /u:login
if %ERRORLEVEL% GTR 0 pause

endlocal
--------------------8<----------------------

The * behind c$ will make net.exe ask for the password,
masking the input.


An alternative is to start the batch file with the computer
name as an input parameter, like this:

mapdrive.bat somecomputer

For that, you can use this version:

--------------------8<----------------------
@echo off
setlocal

net.exe use * \\%1%\c$ * /u:login
if %ERRORLEVEL% GTR 0 pause

endlocal
--------------------8<----------------------



Paul_Boardman said:
I am not sure if I have posted this in the correct area so sorry if that is
the case.

I am trying to devise a generic batch file to map a network drive to any PC.
The way I am trying to get it to work is using something along these lines;

net use * \\computer_name\c$ /u:login

Ideally I want the batch file to run the net use command and then prompt me
for the computer name which i would type in, and then prompt me for the
password of the local login account which again i would type in.

I have tried the following but it only maps a drive to my local PC [which
you would expect]

net use \\%computer_name%\c$ /user:login

I recall using one a few years ago on NT but cannot recall how it worked and
the person who devised it has since left the company.

Is this sort of command still possible? I only ask because I have to map to
a load of PCs to troubleshoot something and I want to try and automate it.

Any help is appreciated, many thanks in advance.

Paul
 
Back
Top