Tuesday, 27 March 2018

How To - Map Network Drives By Batch File Logon Script

Mapping Network Drives Batch File Logon Script - Get yourself out of trouble temporarily if you are having map network drive issues on your network by using this useful logon script

Hello all fellow IT Geeks, Beginners and the alike.

Here is a batch file script you can implement on your domain network to map network drives if you are having issues with user accounts not mapping drives properly through Group Policy. This can get you out of trouble for the interim so that you can concentrate on finding out what the problem is with your drive maps, group policy objects etc. This script can be easily modified and implemented within minutes.


Steps:

  • Create your batch file in notepad and copy and modify the below script
  • Name it accordingly, for this example we named it mapdrives.bat
  • Place/Copy the saved batch file under C:\Windows\SYSVOL\domain\scripts on your domain controller/server
  • In Active Directory implement the script to the users who are having map drive issues - In Active Directory and users, locate the user, go to the profile tab type the name of the script, in this example mapdrives.bat
  • Go to the machine of the user, go to command prompt type in gpupdate /force and reboot
  • Check the results of the group policies being applied gpresult -r
  • If all good when you logon next, you should see command prompt flash when you login and do its magic!

This is a good solution for you to get you out of trouble temporarily whilst you dig around and troubleshoot your network, it can be especially useful for those who have multiple mapped network drives assigned to their profile.

The below script has to be modified accordingly to your environment therefore it is advised that you modify to your network such as the drive letters for example.

I would suggest to test this on a few test machines out before implementing the script to your specific domain users.


@echo off

echo  ---------------------------------------------------------------------------
echo Mapping Network Drives Batch File
echo  ---------------------------------------------------------------------------

net use K: /delete
net use R: /delete
net use V: /delete
net use W: /delete
net use X: /delete
net use Z: /delete
echo

NET USE K: \\dc01\ManagerDrive /persistent:no
echo.
NET USE R: \\dc01\Photos /persistent:no
echo.
NET USE V: \\dc01\software /persistent:no
echo.
NET USE W: \\dc01\GeneralData /persistent:no
echo.
NET USE X: \\server02\Otherdata /persistent:no
echo.
NET USE Z: \\dc01\Homes$\%USERNAME% /persistent:no
echo.



echo.
echo.Time synching now...
NET TIME \\dc01 /SET /YES

echo.
echo  ---------------------------------------------------------------------------
echo LOG - ON Completed
echo  ---------------------------------------------------------------------------

echo.



Thanks and Enjoy!

No comments:

Post a Comment

Coin Watch List November 2021

06/11/2021 Wagyu Swap  https://www.wagyuswap.app/ Contract - 0x7fa7df4996ac59f398476892cfb195ed38543520 Socials https://t.me/WagyuAnn https...