net use Z: \\fileserver\securefolder /user:DOMAIN\username * You will be prompted to enter the password (which remains hidden as you type). By default, mapped drives using net use are not persistent – they disappear after you log off. To make the drive reconnect automatically every time you sign in, use the /persistent:yes flag.
@echo off echo Mapping network drives... net use Z: \\server1\marketing /persistent:yes net use Y: \\server2\finance /user:FinanceUser * net use X: \\server3\backup /persistent:yes echo Mapping complete. pause if not exist Z:\ ( net use Z: \\server\share /persistent:yes ) else ( echo Drive Z already mapped. ) 3. Map Drive Using PowerShell (Alternative) While not cmd , PowerShell is useful in modern scripts: map network drive windows 11 command line
net use Z: \\server\share /user:WORKGROUP\AlternateUser * Sometimes you just need to authenticate to a network location without assigning a letter. Use an asterisk ( * ) as the drive letter, or omit it: @echo off echo Mapping network drives
If you encounter persistent issues, verify network connectivity with ping server-name , check firewall settings, and ensure the "Function Discovery Resource Publication" and "SSDP Discovery" services are running on your Windows 11 machine. use * to prompt interactively:
net use Z: \\server\share /user:WORKGROUP\AlternateUser Password123 /persistent:yes To avoid storing the password in plain text, use * to prompt interactively: