dev.rean.me
windows-server

16 - How to Map Network Drive Using Batch Script with Windows Server 2022 (Video Tutorial in Khmer)

Learn how to map network drive using batch script in Windows Server 2022 step-by-step with video tutorial in Khmer and easy setup tips.

2026-09-04 ยท 4 min read

Share:

Hello my friend! Today I show you step-by-step how to Map Network Drive Using Batch Script in Windows Server 2022! Mapping network drive using a logon batch script automatically connects central company shared folders (like Z:\ drive or S:\ shared drive) to employee computers as soon as they log into Windows! Super easy for staff to save and access department files! Very easy to follow with video tutorial in Khmer! Let's get started!

Map Network Drive Using Batch Script in Windows Server 2022 speak khmer

Step 1: Create Central Shared Network Folder

First, make sure network shared folder exists on server with proper Share and NTFS permissions:

  1. Create folder on server data drive (example: D:\SharedData).
  2. Share folder on network with Share Name SharedData (UNC path: \\SRV-DC01\SharedData).
  3. Ensure domain users have Read or Modify permissions.

๐Ÿ’ก Tip: Test opening network path \\SRV-DC01\SharedData from client PC first to confirm permissions work before writing script!

Step 2: Create Logon Batch Script (.bat)

Now create a simple batch script file using Notepad:

  1. Open Notepad (notepad.exe).
  2. Type commands below to disconnect existing drive letter and map new network drive:
@echo off
rem Delete existing Z drive mapping if already present
net use Z: /delete /yes 2>nul

rem Map Z drive to network shared folder
net use Z: \\SRV-DC01\SharedData /persistent:yes
  1. Save file as MapDrives.bat (make sure Save as type is set to All Files (.), NOT .txt!).

๐Ÿ’ก Tip: Adding net use Z: /delete /yes 2>nul first ensures old or broken drive connections are cleared out automatically before mapping new drive!

Step 3: Copy Script File to NETLOGON Share Folder

Store script file inside Domain Controller NETLOGON system folder so all client computers can execute it:

  1. Open File Explorer on Domain Controller.
  2. Navigate to path:
\\SRV-DC01\NETLOGON

or local path C:\Windows\SYSVOL\sysvol\rean.local\scripts.

  1. Paste your MapDrives.bat file inside this NETLOGON folder.

๐Ÿ’ก Tip: The NETLOGON share is automatically replicated across all Active Directory Domain Controllers in your network!

Step 4: Deploy Logon Script via Group Policy (GPO) or Active Directory User Profile

You can deploy logon script using Group Policy or Active Directory User Profile tab:

  1. Open Group Policy Management (gpmc.msc).
  2. Right-click target OU > select Create a GPO in this domain, and Link it here....
  3. Name GPO: GPO_Map_Network_Drives > right-click > Edit....
  4. Navigate to: User Configuration โ†’ Policies โ†’ Windows Settings โ†’ Scripts (Logon/Logoff)
  5. Double-click Logon > click Add... button.
  6. Click Browse... button (it will automatically open GPO scripts directory) > select MapDrives.bat.
  7. Click Apply and OK.

Method B: Assign in ADUC User Profile Properties

  1. Open Active Directory Users and Computers (dsa.msc).
  2. Double-click user account > switch to Profile tab.
  3. In Logon script field, type file name: MapDrives.bat.
  4. Click OK.

Step 5: Test and Verify Mapped Network Drive on Client PC

Now test on client computer (Windows 10 / Windows 11):

  1. On client computer, open Command Prompt (cmd) and force GPO update:
gpupdate /force
  1. Log off domain user account and log back in.
  2. Open This PC (File Explorer Win + E).
  3. Look under Network locations section:
    • You will see new network drive: SharedData (Z:)!
  4. Double-click Z:\ drive to access shared files immediately!

๐Ÿ’ก Tip: If network drive shows red X icon after rebooting laptop off-site, double-clicking drive icon re-establishes connection automatically once connected to company VPN or Wi-Fi network!

Watch Video Tutorial (Khmer)

Watch full step-by-step video tutorial below to see how to map network drive using batch script in Khmer:


Hope this tutorial help you map network drives using batch script easily! Practice creating logon scripts on your server today. Happy learning my friends! Sharing is caring!