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

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

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

Anthony Martial wraps up loan switch to Sevilla

by 24britishtvJan. 26, 2022, 9 a.m.2
HOT TRENDS

Newcastle make £33.5m offer for Lyon midfielder Bruno Guimarães

by 24britishtvJan. 26, 2022, 9 a.m.2
HOT TRENDS

Can you spot all the Newport locales in "The Gilded Age"?

by 24britishtvJan. 26, 2022, 9 a.m.2
HOT TRENDS

QPR v Swansea ends goalless as Flynn Downes is sent off in stalemate

by 24britishtvJan. 26, 2022, midnight2
HOT TRENDS

Martial completes loan move

by 24britishtvJan. 26, 2022, midnight2
HOT TRENDS

Who is interior designer Lulu Lytle and did she attend PM’s birthday?

by 24britishtvJan. 26, 2022, midnight2
HOT TRENDS

Dion Sanderson joins on loan

by 24britishtvJan. 25, 2022, 11 p.m.2
HOT TRENDS

Championship roundup: Davis helps Nottingham Forest to four straight wins

by 24britishtvJan. 25, 2022, 11 p.m.2
HOT TRENDS

Sainsbury’s issues face mask rule despite warnings for customers

by 24britishtvJan. 25, 2022, 10 p.m.2
HOT TRENDS

How To Win At Wordle: Tips And Tricks To Succeed At The Viral Puzzle Game

by 24britishtvJan. 25, 2022, 10 p.m.2
HOT TRENDS

'Nadal gets preferential treatment'

by 24britishtvJan. 25, 2022, 9 p.m.2
HOT TRENDS

McDonald’s to launch Chicken Big Mac

by 24britishtvJan. 25, 2022, 6 p.m.2
HOT TRENDS

Great chieftain o' the pudding-race: Burns' Address to a Haggis in full

by 24britishtvJan. 25, 2022, 6 p.m.2
HOT TRENDS

Celtic say former manager Wim Jansen will be forever remembered

by 24britishtvJan. 25, 2022, 5 p.m.2
HOT TRENDS

McDonald’s to launch Chicken Big Mac

by 24britishtvJan. 25, 2022, 4 p.m.2