Mapping the shared folders

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
balubeto
Posts: 136
Joined: 08 Dec 2011 12:14

Mapping the shared folders

#1 Post by balubeto » 09 Jul 2017 03:16

Hi

In Windows PE/RE of Windows 10 v1704 (DOS command prompt), what is the procedure to find the shared folders on the network and how do I map them?

Thanks

Bye

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Mapping the shared folders

#2 Post by aGerman » 09 Jul 2017 03:43

Most likely NET USE (execute NET HELP USE to get help).

E.g.

Code: Select all

net use X: /delete /yes
to disconnect if the drive X: was still connected (option /yes is not documented, it forces silent disconnection).

Code: Select all

net use X: "\\servername\share" /persistent:no
to connect drive X: where "servername" can also be an IP address. If "share" contains a drive letter on the server then replace the colon with a Dollar sign (e.g. C$ instead of C:).

Steffen

SIMMS7400
Posts: 546
Joined: 07 Jan 2016 07:47

Re: Mapping the shared folders

#3 Post by SIMMS7400 » 10 Jul 2017 12:33

If you're worried about drive letters, use this piece of code to find an available one:

Code: Select all

SETLOCAL ENABLEDELAYEDEXPANSION

FOR %%D IN ( b d e f g h i j k l m n o p q r s t u v w x y z ) DO (

   IF NOT EXIST %%D:\ (
      SET MD=%%D
      NET USE !MD!: "%DRIVE1%" /USER:%CREDS%
      GOTO BREAK
   )
)
:BREAK

:: Put code here to be acted on related to the recently mapped drive

NET USE %MD%: /delete

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: Mapping the shared folders

#4 Post by Compo » 10 Jul 2017 12:44

SIMMS7400 wrote:If you're worried about drive letters, use this piece of code to find an available one:

<SNIP />

If you type an asterisk, *, instead of a drive letter it will assign the next available drive letter.

Code: Select all

NET USE *

Post Reply