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

Utilizing a little-known function of Home windows 10 and 11, we are able to robotically designate a particular drive letter to Microsoft OneDrive at startup each time we boot up our PC.

Blue computer key - connect to the cloud

Picture: MyImages – Micha/Shutterstock

Beforehand, we outlined a technique for mapping a drive letter to Microsoft OneDrive utilizing the previous “subst” DOS command. This trick was wanted as a result of neither Home windows 10 nor Home windows 11 will permit customers to map OneDrive by standard strategies. Whereas using a DOS command is efficient, it’s not everlasting. Every restart or reboot of your PC will take away the mapping, so we should take the subsequent step to make it fixed.

Within the days of DOS we may make our mapped drive everlasting by an autoexec.bat file that runs throughout the boot course of, however that won’t work with Home windows 10 or Home windows 11. Nonetheless, we are able to nonetheless use a batch file to run our subst command at startup, however provided that we combine the previous with the brand new and hyperlink the file to the appropriate folder.

SEE: OneDrive Cloud Utilization Coverage (TechRepublic Premium)

Completely map OneDrive to a drive letter with a batch file

For these of you not as historic as me, a batch file is a straightforward textual content file that Home windows interprets as a collection of instructions. These are the sorts of instructions you’d subject from the usual command immediate. Most likely one of the best ways to explain it’s that batch recordsdata are a type of scripting

For our functions, we are going to create a easy textual content file with the “.bat” extension with just one line in it. It doesn’t matter the place this batch file is situated, however I might counsel someplace on the working system drive (usually C:). For our instance, we are going to use C:Apps.

Use Home windows File Explorer to navigate to the Apps folder, as proven in Determine A, and right-click on an open space within the righthand window. Choose New | Textual content Doc from the context menu.

Determine A


Give your new textual content file a reputation however make sure you use the .bat extension. For our instance, we used Startup.bat.

Proper-click your batch file and choose Edit from the context menu. Home windows will open Notepad, and you will notice an empty textual content file. Add the subst command that maps your required drive letter to Microsoft One Drive. In my case it’s:

subst z: “c:/Customers/mark/OneDrive – Mark W Kaelin”

Determine B reveals you what it appears like in Notepad.

Determine B


Save the batch file and shut out Notepad. For those who double-click your new batch file, it should run (most likely sooner than you possibly can discover) and OneDrive might be mapped to a drive letter. Nonetheless, to get this batch file to run on startup, we should place a hyperlink to it within the particular Home windows 10 and Home windows 11 Startup folder.

Many customers are unaware of the Home windows Startup folder, however it may be helpful for working any software throughout the boot course of that doesn’t have that function already inbuilt. To achieve it, use the keyboard mixture shortcut Home windows Key + R to open the run command dialog field and sort “shell:startup”, as proven in Determine C.

Determine C


Click on OK to open a session of File Explorer pointing to the Home windows Startup folder, as proven in Determine D. Proper-click an open space within the righthand window and choose New | Shortcut. You may be offered with a dialog field the place you possibly can browse to your batch file.

Determine D


Browse to the place you saved your batch file (Determine E). Once you discover the file, click on on it, after which click on the OK button. Click on Subsequent after which End. Shut out File Explorer if you end up executed.

Determine E


Now, whenever you have a look at the Home windows Startup folder, you will notice a hyperlink to your batch file. So long as that shortcut is within the Home windows Startup folder, Microsoft OneDrive might be mapped to a particular drive letter based on your preferences whenever you boot your PC.

For those who resolve you now not need Microsoft OneDrive mapped to a drive letter each time you boot your PC, merely take away the shortcut hyperlink from the Home windows Startup folder.

Additionally see

Recent Articles


Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here

Stay on op - Ge the daily news in your inbox