How to permanently map OneDrive to a drive letter using a batch file

by 24britishtvJan. 11, 2022, 4 a.m. 80
-

Using a little-known feature of Windows 10 and 11, we can automatically designate a specific drive letter to Microsoft OneDrive at startup every time we boot up our PC.

Previously, we outlined a method for mapping a drive letter to Microsoft OneDrive using the old "subst" DOS command. This trick was needed because neither Windows 10 nor Windows 11 will allow users to map OneDrive through conventional methods. While the use of a DOS command is effective, it is not permanent. Each restart or reboot of your PC will remove the mapping, so we must take the next step to make it constant.

In the days of DOS we could make our mapped drive permanent through an autoexec.bat file that runs during the boot process, but that will not work with Windows 10 or Windows 11. However, we can still use a batch file to run our subst command at startup, but only if we mix the old with the new and link the file to the right folder.

For those of you not as ancient as me, a batch file is a simple text file that Windows interprets as a series of commands. These are the kinds of commands you would issue from the standard command prompt. Probably the best way to describe it is that batch files are a form of scripting

For our purposes, we will create a simple text file with the ".bat" extension with only one line in it. It does not matter where this batch file is located, but I would suggest somewhere on the operating system drive (typically C:). For our example, we will use C:\Apps.

Use Windows File Explorer to navigate to the Apps folder, as shown in Figure A, and right-click on an open area in the righthand window. Select New | Text Document from the context menu.

Give your new text file a name but be sure to use the .bat extension. For our example, we used Startup.bat.

Right-click your batch file and select Edit from the context menu. Windows will open Notepad, and you will see an empty text file. Add the subst command that maps your desired drive letter to Microsoft One Drive. In my case it is:

Figure B shows you what it looks like in Notepad.

Save the batch file and close out Notepad. If you double-click your new batch file, it will run (probably faster than you can notice) and OneDrive will be mapped to a drive letter. However, to get this batch file to run on startup, we will have to place a link to it in the special Windows 10 and Windows 11 Startup folder.

Many users are unaware of the Windows Startup folder, but it can be useful for running any application during the boot process that does not have that feature already built in. To reach it, use the keyboard combination shortcut Windows Key + R to open the run command dialog box and type "shell:startup", as shown in Figure C.

Click OK to open a session of File Explorer pointing to the Windows Startup folder, as shown in Figure D. Right-click an open area in the righthand window and select New | Shortcut. You will be presented with a dialog box where you can browse to your batch file.

Browse to where you stored your batch file (Figure E). When you find the file, click on it, and then click the OK button. Click Next and then Finish. Close out File Explorer when you are done.

Now, when you look at the Windows Startup folder, you will see a link to your batch file. As long as that shortcut is in the Windows Startup folder, Microsoft OneDrive will be mapped to a specific drive letter according to your preferences when you boot your PC.

If you decide you no longer want Microsoft OneDrive mapped to a drive letter every time you boot your PC, simply remove the shortcut link from the Windows Startup folder.
• How to map OneDrive to a drive letter in Windows 11 (TechRepublic)
• How to use OneDrive with Microsoft 365 desktop (TechRepublic)
• How to use a batch file to reset and renew a network connection in Windows 10 (TechRepublic)
• Keep your Windows sessions alive and ready with this PowerShell script (TechRepublic)
• How to add Safe Mode to the boot menu in Windows 11 (TechRepublic)
• Zoom vs. Microsoft Teams, Google Meet, Cisco WebEx and Skype: Choosing the right video-conferencing apps for you (free PDF) (TechRepublic)

-

Related Articles

HOT TRENDS

Nation commemorates Anzac Day to remember the fallen

by 24britishtvApril 25, 2024, 10:01 a.m.2
HOT TRENDS

Dramatic Emmerdale exit as character is jailed for nearly a decade

by 24britishtvApril 25, 2024, 10 a.m.2
HOT TRENDS

Atalanta vs Fiorentina: Lineups and how to watch

by 24britishtvApril 25, 2024, 5:01 a.m.2
HOT TRENDS

Official: Cleverley Confirmed As Permanent Head Coach

by 24britishtvApril 25, 2024, 1:01 a.m.2
HOT TRENDS

South Mole & Access for Seniors - Letter to the Editor

by 24britishtvApril 25, 2024, 12:01 a.m.2
HOT TRENDS

Hull win at Coventry to keep play-off hopes alive

by 24britishtvApril 24, 2024, 11:01 p.m.2
HOT TRENDS

Impressive Everton win to hit Liverpool title hopes

by 24britishtvApril 24, 2024, 11:01 p.m.2
HOT TRENDS

Who are the best Chelsea picks for their TWO Double Gameweeks?

by 24britishtvApril 24, 2024, 10:01 p.m.2
HOT TRENDS

Man Utd fight back twice to beat Sheff Utd late on

by 24britishtvApril 24, 2024, 10:01 p.m.2
HOT TRENDS

Blood on pavement and smashed vehicles after horses tear through London

by 24britishtvApril 24, 2024, 9 p.m.2
HOT TRENDS

Liverpool sign scores football makeover

by 24britishtvApril 24, 2024, 8:01 p.m.2
HOT TRENDS

Team News: One change for Palace against Newcastle - News

by 24britishtvApril 24, 2024, 8:01 p.m.2
HOT TRENDS

Four taken to hospital after military horses break loose in central London

by 24britishtvApril 24, 2024, 8:01 p.m.2
HOT TRENDS

LIVE: Everton vs Liverpool – Premier League football

by 24britishtvApril 24, 2024, 8:01 p.m.2
HOT TRENDS

Premier League: Everton host Liverpool plus three more games

by 24britishtvApril 24, 2024, 7 p.m.2
HOT TRENDS

How to watch Wolves vs Bournemouth

by 24britishtvApril 24, 2024, 7 p.m.2
HOT TRENDS

Makes Highly Anticipated Return To Manchester On July 27 With 304

by 24britishtvApril 24, 2024, 6:01 p.m.2
HOT TRENDS

Elon Musk Just Got Much Richer From Tesla Stock's Historic Post-Earnings Bump

by 24britishtvApril 24, 2024, 4:01 p.m.2
HOT TRENDS

Why 2023/24 is on course to smash RECORD goals total

by 24britishtvApril 24, 2024, 4 p.m.2
HOT TRENDS

Kylie Jenner pregnancy rumours with Timothée Chalamet explained

by 24britishtvApril 24, 2024, 4 p.m.2