How to add "Send to SkyDrive" to the Windows Explorer context menu in Windows 8.1 (PowerShell)
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: Run the script with PowerShell.
Step 2: A few minutes later, a message will be prompted and the items will be added to the context menu.
Result:
Here are some code snippets for your reference:
$Target = $env:USERPROFILE + "\SkyDrive"
If(Test-Path -Path Target)
{
Write-Warning "There is no SkyDrive or the SkyDrive is not in default path."
}
Else
{
#Get shortcut path
$shortcutpath = $env:APPDATA + "\Microsoft\Windows\SendTo\SkyDrive.lnk"
If(Test-path -Path $shortcutpath)
{
#Display a prompt
$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes",""
$no = New-Object System.Management.Automation.Host.ChoiceDescription "&No",""
$choices = [System.Management.Automation.Host.ChoiceDescription[]]($yes,$no)
$caption = "Confirming"
$message = "'Send to SkyDrive' already exists, do you want remove it?"
$result = $Host.UI.PromptForChoice($caption,$message,$choices,0)
If($result -eq 0)
{
Remove-Item -Path $shortcutpath -Force
Write-Host "Remove successfully."
}
}
Else
{
#Create a shortcut
$wshell = New-Object -ComObject WScript.Shell
$shortcut = $wshell.CreateShortcut($shortcutpath)
$shortcut.Targetpath = $Target
$shortcut.Save()
Write-host "Create 'Send to SkyDrive' successfully." -ForegroundColor Green
}
}
cmd /c pause
$Target = $env:USERPROFILE + "\SkyDrive"
If(Test-Path -Path Target)
{
Write-Warning "There is no SkyDrive or the SkyDrive is not in default path."
}
Else
{
#Get shortcut path
$shortcutpath = $env:APPDATA + "\Microsoft\Windows\SendTo\SkyDrive.lnk"
If(Test-path -Path $shortcutpath)
{
#Display a prompt
$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes",""
$no = New-Object System.Management.Automation.Host.ChoiceDescription "&No",""
$choices = [System.Management.Automation.Host.ChoiceDescription[]]($yes,$no)
$caption = "Confirming"
$message = "'Send to SkyDrive' already exists, do you want remove it?"
$result = $Host.UI.PromptForChoice($caption,$message,$choices,0)
If($result -eq 0)
{
Remove-Item -Path $shortcutpath -Force
Write-Host "Remove successfully."
}
}
Else
{
#Create a shortcut
$wshell = New-Object -ComObject WScript.Shell
$shortcut = $wshell.CreateShortcut($shortcutpath)
$shortcut.Targetpath = $Target
$shortcut.Save()
Write-host "Create 'Send to SkyDrive' successfully." -ForegroundColor Green
}
}
cmd /c pause
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.