How to remove OneDrive from the Windows Explorer Navigation pane in Windows 8.1 (VBScript)

Introduction

This script is to remove OneDrive from the Windows Explorer Navigation pane in Windows 8.1.

Scenarios

Some users want to remove OneDrive from the Windows Explorer Navigation pane due to some reasons.

Script

Step 1: Double click the script and it will ask for administrator permission.

 

Step 2: Then after the script finishes execution, you will need to restart your computer to take effect.

Note  Do not move or delete the folder Takeown and its subfolders and files.

Here are some code snippets for your reference:

VB Script
Edit|Remove
If Err.Number =0 Then  
    Set objshell = CreateObject("shell.application") 
    objshell.ShellExecute "cmd.exe"" /c Powershell.exe -noexit "  & pspath, "" ,"Runas"0 
    If returnvalue = -260016771 Then  
        wshell.RegWrite regpath, -1626865587"REG_DWORD" 
        choice =  MsgBox("You have removed the OneDrive from Windows explorer navigation, you need to restart computer to take  
effect.",1,"Restart Computer") 
wscript.echo choice 
         If choice = 1  Then  
             wshell.run "cmd.exe /c shutdown -r" 
         End  If  
    ElseIf returnvalue = -1626865587 Then  
        wshell.RegWrite regpath, -260016771"REG_DWORD" 
        choice =  MsgBox("You have added OneDrive from Windows explorer navigation, you need to restart computer to take  
effect.",1,"Restart Computer") 
        wscript.echo choice 
         If choice = 1  Then  
             wshell.run "cmd.exe /c shutdown -r" 
         End If  
    End If  
Else  
    WScript.Echo "Not find OneDrive installed." 
End If 

Prerequisite

Windows 8 or higher version

OneDrive

Microsoft All-In-One Script Framework is an automation script sample library for IT Professionals. The key value that All-In-One Script Framework is trying to deliver is Scenario-Focused Script Samples driven by IT Pros' real-world pains and needs. The team is monitoring all TechNet forums, IT Pros' support calls to Microsoft, and script requests submitted to TechNet Script Repository. We collect frequently asked IT scenarios, and create script samples to automate the tasks and save some time for IT Pros. The team of All-In-One Script Framework sincerely hope that these customer-driven automation script samples can help our IT community in this script-centric move.