Created
March 4, 2026 21:55
-
-
Save rmtbb/28c281dae4e27e71f9623a6c6af9aa9b to your computer and use it in GitHub Desktop.
Persistent Non Intrusive NAS SMB Drive Mapping Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| set "DRIVE=Z:" | |
| set "SHARE=\\10.10.10.10\media" | |
| set "USER=USER" | |
| set "PASS=PASSWORD" | |
| rem If Z: exists (mapped or local), do not touch it | |
| if exist %DRIVE%\ ( | |
| exit /b 0 | |
| ) | |
| rem Map only if unused | |
| net use %DRIVE% "%SHARE%" /user:%USER% "%PASS%" /persistent:yes >nul 2>&1 | |
| exit /b %errorlevel% |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
1. Save the script
Save your file as
C:\Scripts\map-nas.bat2. Open Task Scheduler
3. Create the task
4. Trigger
Select:
Click Next
5. Action
Select:
Click Next
Program/script:
Click Next → Finish
✅ Done.
Now when the user logs in, it runs the script and only maps Z: if it doesn't already exist.