I found this:
https://stackoverflow.com/questions/16233165/how-to-pin-application-icon-to-the-metro-start-screen-in-windows-8-programmatica?rq=4
It's for Windows 8, but it's for the "Metro" style of the start menu. It may still work.
If you'd like to try it, here's the PowerShell version (UNTESTED!!):
function PinToStart {
param (
[string]$filePath
)
$success = $false
# Break into file name and path
$directoryName = [System.IO.Path]::GetDirectoryName($filePath)
$fileName = [System.IO.Path]::GetFileName($filePath)
# Load shell32.dll
$shell32 = Add-Type -MemberDefinition @"
[DllImport("shell32.dll", CharSet = CharSet.Auto)]
public static extern int LoadString(IntPtr hInstance, int uID, System.Text.StringBuilder lpBuffer, int nBufferMax);
"@ -Name "Shell32" -Namespace "Win32" -PassThru
$hShell32 = [System.Runtime.InteropServices.Marshal]::GetHINSTANCE([System.Reflection.Assembly]::GetExecutingAssembly().GetModules()[0])
if ($hShell32 -ne [IntPtr]::Zero) {
# Get the localized translation of 'Pin to Start' verb
$szPinToStartLocalized = New-Object System.Text.StringBuilder 256
$nPinToStartLocalizedLength = [Win32.Shell32]::LoadString($hShell32, 51201, $szPinToStartLocalized, $szPinToStartLocalized.Capacity)
if ($nPinToStartLocalizedLength -gt 0) {
# Create the shell object
$shell = New-Object -ComObject Shell.Application
$folder = $shell.Namespace($directoryName)
if ($folder -ne $null) {
$item = $folder.ParseName($fileName)
if ($item -ne $null) {
$verbs = $item.Verbs()
for ($i = 0; $i -lt $verbs.Count; $i++) {
$verb = $verbs.Item($i)
if ($verb.Name -eq $szPinToStartLocalized.ToString()) {
$verb.DoIt()
$success = $true
break
}
}
}
}
}
[System.Runtime.InteropServices.Marshal]::FreeHGlobal($hShell32)
}
return $success
}
# Example usage
PinToStart "C:\Path\To\Your\File.txt"
The original code was written in C++ so you can't (without some work) use the Add-Type cmdlet to add the original code to your program as you can with C#.