Anyone who can read the .bat file can see the credentials.
echo Y | net use * /delete
net use Z: \\Server01\Projects /persistent:no
(The system will prompt: "Type the password for AdminUser:" with hidden input.) cmd command to map network drive
net use Z: \\Server01\Documents /persistent:yes
net use Z: /delete
To wipe all current network connections in one command (useful for login scripts to start fresh): Anyone who can read the
net use Z: "\\Server01\Project Files\Q1 Reports"
To remove a specific mapped drive:
@echo off echo Mapping network drives for user %username%... cmd command to map network drive
:: Delete existing connections to start clean net use * /delete /yes
net use [drive letter:] \\server\share [/persistent:yes/no]