How to add "Send to SkyDrive" to the Windows Explorer context menu in Windows 8.1 (VBScript)
Introduction
The goal of this script is to add "Send to SkyDrive" to the Windows Explorer context menu in Windows 8.1.
Scenarios
Windows 8.1 is integrated with SkyDrive. If we want to copy some files or folders to SkyDrive folder, we need to copy and paste them. If there is an item "send to SkyDrive" in context menu, it will be more convenient for users to achieve this target.
Script
Step 1: Double-click the script.
Step 2: A few minutes later, the items will be added to the context menu.
Result:
Here are some code snippets for your reference:
Dim objshell, Target, UserFile, Appdata, FSO, intAnswer, ShortCut, path
'Create wscript.shell object
Set objshell = CreateObject("wscript.shell")
'Create FileSystemObject
Set FSO = CreateObject("Scripting.FileSystemObject")
'Get user profile path
UserFile = objshell.ExpandEnvironmentStrings("%UserProfile%")
'SkyDrive path
Target = UserFile & "\SkyDrive"
WScript.Echo Target
If FSO.FolderExists(Target) Then
Appdata = objshell.ExpandEnvironmentStrings("%APPDATA%")
'ShortCut path
path = Appdata & "\Microsoft\Windows\SendTo\SkyDrive.lnk"
'Check if shortcut exists
If FSO.FileExists(path) Then
intAnswer = MsgBox ("'Send to SkyDrive' already exists, do you want remove it?",vbYesNo, "Delete File")
If intAnswer = vbYes Then
FSO.DeleteFile path
WScript.Echo "Remove 'Send to SkyDrive' successfully."
End If
Else
'Create shortcut
Set ShortCut = objshell.CreateShortcut(path)
ShortCut.Targetpath = Target
ShortCut.save
WScript.Echo "Create 'Send to SkyDrive' successfully."
End If
Else
WScript.Echo "There is no SkyDrive or the SkyDrive is not in default path."
End If
Dim objshell, Target, UserFile, Appdata, FSO, intAnswer, ShortCut, path
'Create wscript.shell object
Set objshell = CreateObject("wscript.shell")
'Create FileSystemObject
Set FSO = CreateObject("Scripting.FileSystemObject")
'Get user profile path
UserFile = objshell.ExpandEnvironmentStrings("%UserProfile%")
'SkyDrive path
Target = UserFile & "\SkyDrive"
WScript.Echo Target
If FSO.FolderExists(Target) Then
Appdata = objshell.ExpandEnvironmentStrings("%APPDATA%")
'ShortCut path
path = Appdata & "\Microsoft\Windows\SendTo\SkyDrive.lnk"
'Check if shortcut exists
If FSO.FileExists(path) Then
intAnswer = MsgBox ("'Send to SkyDrive' already exists, do you want remove it?",vbYesNo, "Delete File")
If intAnswer = vbYes Then
FSO.DeleteFile path
WScript.Echo "Remove 'Send to SkyDrive' successfully."
End If
Else
'Create shortcut
Set ShortCut = objshell.CreateShortcut(path)
ShortCut.Targetpath = Target
ShortCut.save
WScript.Echo "Create 'Send to SkyDrive' successfully."
End If
Else
WScript.Echo "There is no SkyDrive or the SkyDrive is not in default path."
End If
Prerequisite
Windows 8.1
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.