Follow Steps :-
2. Now in the Local Group Policy editor window go to
User Configuration > Administrative Templates > Windows Components > Windows Explorer
3. Now in the right pane you will see a list of settings. Scroll down until you find the setting named “Prevent access to drives from My Computer“.
4. Double click the setting to open the setting window. Now select Enabled.
Now in the left pane you will find a drop-down where you can select the drive you want a restricted access.
You can also choose to restrict all the drives. Now press Apply and then OK.
Now that you are done, double clicking the selected (restricted) drives will throw an error window as shown below.