To map network share via batch script I am using this simple script
set DRIVE_LETTER=<drive-letter>
set SERVER_NAME=<your-server-name>
set SHARE_NAME=<share-name>
set DOMAIN_NAME=<domain-name>
net use %DRIVE_LETTER%: /delete /yes
net use %DRIVE_LETTER%: \\%SERVER_NAME%\%SHARE_NAME% /user:%DOMAIN_NAME%\%USERNAME% /persistent:yes
Where:
DRIVE_LETTER - the letter under which would be the network share mapped, i.e. W:
SERVER_NAME - it could be IP address or local server name (if DNS is properly setup), i.e. server.example.local
SHARE_NAME - name of the network share that we want to map, i.e. documents
DOMAIN_NAME - your local domain name (Active Direcotory or Linux Samba AD), i.e EXAMPLE
%USERNAME% - used in a script gets current username, i.e jdoe