Replies: 3 comments 4 replies
-
Easy! You prefer me to add code here or in the Telegram group? |
Beta Was this translation helpful? Give feedback.
2 replies
-
I'll send tomorrow. It's 0:30 pm) |
Beta Was this translation helpful? Give feedback.
1 reply
-
Clear-Host
if (-not (Get-Package -ProviderName msi -Name "PowerShell 7*x64"))
{
exit
}
$Parameters = @{
Size = "2x2"
Column = 0
Row = 0
AppID = "Microsoft.AutoGenerated.{A49227EA-5AF0-D494-A3F1-0918A278ED71}" # PowerShell 7 x64
# AppID = "Microsoft.AutoGenerated.{CD9EFC53-1ACE-EA00-530A-3EC179D1971C}" # PowerShell 7 Preview x64
}
[string]$StartLayoutNS = "http://schemas.microsoft.com/Start/2014/StartLayout"
# Add pre-configured hastable to XML
function Add-Tile
{
param
(
[string]
$Size,
[int]
$Column,
[int]
$Row,
[string]
$AppID
)
[string]$elementName = "start:DesktopApplicationTile"
[Xml.XmlElement]$Table = $xml.CreateElement($elementName, $StartLayoutNS)
$Table.SetAttribute("Size", $Size)
$Table.SetAttribute("Column", $Column)
$Table.SetAttribute("Row", $Row)
$Table.SetAttribute("DesktopApplicationID", $AppID)
return $Table
}
# Export the current Start layout
$StartLayout = "$PSScriptRoot\StartLayout.xml"
Export-StartLayout -Path $StartLayout -UseDesktopApplicationID
[xml]$XML = Get-Content -Path $StartLayout -Encoding UTF8 -Force
$Groups = $XML.LayoutModificationTemplate.DefaultLayoutOverride.StartLayoutCollection.StartLayout.Group
# Create a new group
[Xml.XmlElement]$Groups = $XML.CreateElement("start:Group", $StartLayoutNS)
$Groups.SetAttribute("Name","")
$Groups.AppendChild((Add-Tile @Parameters)) | Out-Null
$XML.LayoutModificationTemplate.DefaultLayoutOverride.StartLayoutCollection.StartLayout.AppendChild($Groups) | Out-Null
$XML.Save($StartLayout)
# Temporarily disable changing the Start menu layout
if (-not (Test-Path -Path HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer))
{
New-Item -Path HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Force
}
New-ItemProperty -Path HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name LockedStartLayout -Value 1 -Force
New-ItemProperty -Path HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name StartLayoutFile -Value $StartLayout -Force
Start-Sleep -Seconds 3
# Restart the Start menu
Stop-Process -Name StartMenuExperienceHost -Force -ErrorAction Ignore
# Open the Start menu to load the new layout
$wshell = New-Object -ComObject WScript.Shell
$wshell.SendKeys("^{ESC}")
Start-Sleep -Seconds 3
# Enable changing the Start menu layout
Remove-ItemProperty -Path HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name LockedStartLayout -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name StartLayoutFile -Force -ErrorAction Ignore
Remove-Item -Path $StartLayout -Force
Stop-Process -Name StartMenuExperienceHost -Force -ErrorAction Ignore
Start-Sleep -Seconds 3
# Open the Start menu to load the new layout
$wshell = New-Object -ComObject WScript.Shell
$wshell.SendKeys("^{ESC}")
# Run the PowerShell 7 x64 shortcut as Administrator
[byte[]]$bytes = Get-Content -Path "$env:ProgramData\Microsoft\Windows\Start Menu\Programs\PowerShell 7 (x64).lnk" -Encoding Byte -Raw
$bytes[0x15] = $bytes[0x15] -bor 0x20
Set-Content -Path "$env:ProgramData\Microsoft\Windows\Start Menu\Programs\PowerShell 7 (x64).lnk" -Value $bytes -Encoding Byte -Force Based on https://github.com/farag2/Utilities/tree/master/Windows%20Terminal |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
farag2
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
how i create a new function to add to start menu pin pscore?
Beta Was this translation helpful? Give feedback.
All reactions