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

2 years ago 583

Using a little-known diagnostic of Windows 10 and 11, we tin automatically designate a circumstantial thrust missive to Microsoft OneDrive astatine startup each clip we footwear up our PC.

Blue machine  cardinal  - link  to the cloud

Image: MyImages - Micha/Shutterstock

Previously, we outlined a method for mapping a thrust missive to Microsoft OneDrive utilizing the aged "subst" DOS command. This instrumentality was needed due to the fact that neither Windows 10 nor Windows 11 volition let users to representation OneDrive done accepted methods. While the usage of a DOS bid is effective, it is not permanent. Each restart oregon reboot of your PC volition region the mapping, truthful we indispensable instrumentality the adjacent measurement to marque it constant.

In the days of DOS we could marque our mapped thrust imperishable done an autoexec.bat record that runs during the footwear process, but that volition not enactment with Windows 10 oregon Windows 11. However, we tin inactive usage a batch record to tally our subst bid astatine startup, but lone if we premix the aged with the caller and nexus the record to the close folder.

SEE: OneDrive Cloud Usage Policy (TechRepublic Premium)

Permanently representation OneDrive to a thrust missive with a batch file

For those of you not arsenic past arsenic me, a batch record is simply a elemental substance record that Windows interprets arsenic a bid of commands. These are the kinds of commands you would contented from the modular bid prompt. Probably the champion mode to picture it is that batch files are a signifier of scripting

For our purposes, we volition make a elemental substance record with the ".bat" hold with lone 1 enactment successful it. It does not substance wherever this batch record is located, but I would suggest determination connected the operating strategy thrust (typically C:). For our example, we volition usage C:\Apps.

Use Windows File Explorer to navigate to the Apps folder, arsenic shown successful Figure A, and right-click connected an unfastened country successful the righthand window. Select New | Text Document from the discourse menu.

Figure A

a-permanently-map-onedrive-batch-file.jpg

Give your caller substance record a sanction but beryllium definite to usage the .bat extension. For our example, we utilized Startup.bat.

Right-click your batch record and prime Edit from the discourse menu. Windows volition unfastened Notepad, and you volition spot an bare substance file. Add the subst bid that maps your desired thrust missive to Microsoft One Drive. In my lawsuit it is:

subst z: "c:/Users/mark/OneDrive - Mark W Kaelin"

Figure B shows you what it looks similar successful Notepad.

Figure B

b-permanently-map-onedrive-batch-file.jpg

Save the batch record and adjacent retired Notepad. If you double-click your caller batch file, it volition tally (probably faster than you tin notice) and OneDrive volition beryllium mapped to a thrust letter. However, to get this batch record to tally connected startup, we volition person to spot a nexus to it successful the peculiar Windows 10 and Windows 11 Startup folder.

Many users are unaware of the Windows Startup folder, but it tin beryllium utile for moving immoderate exertion during the footwear process that does not person that diagnostic already built in. To scope it, usage the keyboard operation shortcut Windows Key + R to unfastened the tally bid dialog container and benignant "shell:startup", arsenic shown successful Figure C.

Figure C

c-permanently-map-onedrive-batch-file.jpg

Click OK to unfastened a league of File Explorer pointing to the Windows Startup folder, arsenic shown successful Figure D. Right-click an unfastened country successful the righthand model and prime New | Shortcut. You volition beryllium presented with a dialog container wherever you tin browse to your batch file.

Figure D

d-permanently-map-onedrive-batch-file.jpg

Browse to wherever you stored your batch record (Figure E). When you find the file, click connected it, and past click the OK button. Click Next and past Finish. Close retired File Explorer erstwhile you are done.

Figure E

e-permanently-map-onedrive-batch-file.jpg

Now, erstwhile you look astatine the Windows Startup folder, you volition spot a nexus to your batch file. As agelong arsenic that shortcut is successful the Windows Startup folder, Microsoft OneDrive volition beryllium mapped to a circumstantial thrust missive according to your preferences erstwhile you footwear your PC.

If you determine you nary longer privation Microsoft OneDrive mapped to a thrust missive each clip you footwear your PC, simply region the shortcut nexus from the Windows Startup folder.

Microsoft Weekly Newsletter

Be your company's Microsoft insider by speechmaking these Windows and Office tips, tricks, and cheat sheets. Delivered Mondays and Wednesdays

Sign up today

Also see

Read Entire Article