Cmd Map Network Drive Better [upd] -
for a deep dive into the complex world of mapping drives for Windows Services. Are you looking to automate this for multiple users via a script, or just for your own local machine Guide: How to Map a Network Drive in Windows - NinjaOne
This suppresses all output. If it fails, it fails quietly – ideal for background logon scripts.
Running net use from an elevated Command Prompt (admin) maps drives in the admin session only—you won’t see them in your normal user’s File Explorer. To map drives for your current logged-on user , run cmd as that user (not elevated). cmd map network drive better
net use | find "OK" > nul if errorlevel 1 ( echo Some drives are disconnected. Reconnecting... net use /PERSISTENT:YES )
You’ve just mapped a drive in under 10 seconds, with no dialogs, and it will survive a reboot. That’s what “better” looks like. for a deep dive into the complex world
To change the default for the entire session without mapping a drive:
| Feature | CMD ( net use ) | PowerShell ( New-PSDrive ) | | :--- | :--- | :--- | | Persistent across reboots | ✅ (with /persistent ) | ❌ (requires separate script or -Persist in PS 5.0+) | | Map as different user | ✅ Easy ( /user: ) | ❌ (Requires -Credential and often fails with double-hop) | | Map as SYSTEM account | ✅ Works | ❌ (Limited) | | Map to a folder (not drive letter) | ❌ | ✅ (PSProvider path) | | Speed | Fastest | Slower (loads modules) | Running net use from an elevated Command Prompt
Instead of clicking through dialogs, use this:
The * prompts for password (hidden input). Safer than typing password in plain text.
| Action | Command | |--------|---------| | Map drive | net use Z: \\server\share | | Persistent | net use Z: \\server\share /p:yes | | With different user | net use Z: \\server\share /user:NAME * | | Delete mapping | net use Z: /delete | | List mappings | net use | | Map without letter | net use \\server\share |