我正在编写一个脚本,按照我的喜好清理全新安装的 Windows 11。有人知道使用 PowerShell 取消固定开始菜单中所有应用的方法吗?我有找到脚本但是这些脚本是依赖于名称的,如果 Windows 只是想在其中包含一个新的应用程序怎么办?
我已阅读固定的应用程序位于
%LocalAppData%\Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState
但是当我到达这个位置时,它是一个二进制文件 :( 我原本以为这里包含了所有的快捷方式,但我想不是
我知道所有开始菜单应用程序在哪里:C:\ProgramData\Microsoft\Windows\Start Menu\Programs
,但我不关心这个,因为它不在最前面和最中间,我想删除的是那些固定的应用程序
编辑:
弗兰肯斯坦化一些代码
function Pin-App { param(
[string]$appname,
[switch]$unpin
)
try{
if ($unpin.IsPresent){
((New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ?{$_.Name -eq $appname}).Verbs() | ?{$_.Name.replace('&','') -match 'Von "Start" lösen|Unpin from Start'} | %{$_.DoIt()}
return "App '$appname' unpinned from Start"
}else{
((New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ?{$_.Name -eq $appname}).Verbs() | ?{$_.Name.replace('&','') -match 'An "Start" anheften|Pin to Start'} | %{$_.DoIt()}
return "App '$appname' pinned to Start"
}
}catch{
Write-Error "Error Pinning/Unpinning App! (App-Name correct?): '$appname' "
}
}
$list = (Get-StartApps).Name;
@($list).Count
foreach ($item in $list) {
Pin-App $item -unpin
};
这似乎有效,但它开始取消固定一些奇怪的东西,例如
App 'Firefox' unpinned from Start
但 Firefox 仍然存在
答案1
我发现了一个不太好但有效的方法。你所要做的就是从另一台按你的喜好设置或完全空白的机器上获取start2.bin文件,然后使用脚本来终止explorer.exe并将bin移到文件夹中
%LocalAppData%\Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState
我将 Windows 11 家庭版箱移至企业版(另一台机器上的沙盒),似乎运行良好。
我应该提一下,由于这些机器是 22H2,所以它是 start2.bin。
这将不会自动为每个用户更改菜单。
如果你想自动更改所有用户的所有固定应用程序,请执行此操作
创造像这样的新目录列表
C:\Users\Default\AppData\Local\Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState
从捐赠者电脑复制相同的 start2.bin 文件和此用户目录中的所有其他内容,并将其粘贴到这里。将文件权限更改为系统作为主人。
编辑:如果你想让每个新登录的用户都有预设您应该能够在这里修改/添加这些文件。
C:\Users\Default\AppData\Local\Microsoft\Windows\Shell
Note: this will not remove Edge, Settings, and Explorer from being pinned.
创建一个文件LayoutModification.json
并以这种格式设置您想要的默认固定应用程序。
{"primaryOEMPins":[{"desktopAppLink":"%ALLUSERSPROFILE%\\Microsoft\\Windows\\Start Menu\\Programs\\Outlook.lnk"},{"desktopAppLink":"%ALLUSERSPROFILE%\\Microsoft\\Windows\\Start Menu\\Programs\\Google Chrome.lnk"},{"desktopAppLink":"%ALLUSERSPROFILE%\\Microsoft\\Windows\\Start Menu\\Programs\\Excel.lnk"}]}
每次新用户登录时都应按照您喜欢的方式进行设置。
我也在默认用户上使用此注册表设置来修改每个新用户首次登录时
::THIS INSTALLS REGISTRY ITEMS INTO THE DEFUALT REGISTRY HIVE:
::THIS IS LOADS THE DEFAULT HIVE FOR ALL USERS
reg load HKLM\DEFAULT c:\users\default\ntuser.dat
::THIS MIGHT REMOVE TIKTOK AND OTHER JUNK FROM START MENU ON NEW USER LOGIN/CREATE
REG ADD "HKLM\default\SOFTWARE\Policies\Microsoft\Windows\CloudContent" /v DisableCloudOptimizedContent /t REG_DWORD /d 1 /f
REG ADD "HKLM\default\SOFTWARE\Policies\Microsoft\Windows\CloudContent" /v DisableConsumerAccountStateContent /t REG_DWORD /d 1 /f
reg add "HKLM\default\Software\Policies\Microsoft\Windows\CloudContent" /v DisableWindowsConsumerFeatures /d 1 /t REG_DWORD /f
reg add "HKLM\default\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v ContentDeliveryAllowed /d 0 /t REG_DWORD /f
reg add "HKLM\default\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v SilentInstalledAppsEnabled /d 0 /t REG_DWORD /f
reg add "HKLM\default\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v SystemPaneSuggestionsEnabled /d 0 /t REG_DWORD /f
::THIS Disables Privacy Settings Experience Using Registry TESTED ON W11 AND WORKS
REG ADD "HKLM\default\SOFTWARE\Policies\Microsoft\Windows\OOBE" /v DisablePrivacyExperience /t REG_DWORD /d 1 /f
::THIS CHANGES TASKBAR TO THE LEFT
REG ADD "HKLM\default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v TaskbarAl /t REG_DWORD /d 0 /f
::THIS REMOVES WIDGETS FROM TASKBAR
REG ADD "HKLM\default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v TaskbarDa /t REG_DWORD /d 0 /f
::THIS REMOVES SEARCH FROM TASKBAR
REG ADD "HKLM\default\Software\Microsoft\Windows\CurrentVersion\Search" /v SearchboxTaskbarMode /t REG_DWORD /d 0 /f
::THIS REMOVES TASK VIEW FROM TASKBAR
REG ADD "HKLM\default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v ShowTaskViewButton /t REG_DWORD /d 0 /f
::THIS REMOVES CHAT FROM TASKBAR
REG ADD "HKLM\default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v TaskbarMn /t REG_DWORD /d 0 /f
::THIS DISABLE CLOUD CONTENT SEARCH FOR ALL USERS
REG ADD "HKLM\default\SOFTWARE\Policies\Microsoft\Windows\Windows Search" /v AllowCloudSearch /t REG_DWORD /d 0 /f
::THIS IS DARK MODE
Reg.exe add "HKLM\default\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize" /v "AppsUseLightTheme" /t REG_DWORD /d "0" /f
Reg.exe add "HKLM\default\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize" /v "SystemUsesLightTheme" /t REG_DWORD /d "0" /f
::THIS IS EXPLORER TO THIS PC
Reg.exe add "HKLM\default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "LaunchTo" /t REG_DWORD /d "1" /f
::THIS IS REMOVE QUICK ACCESS
Reg.exe add "HKLM\default\Software\Microsoft\Windows\CurrentVersion\Explorer" /v HubMode /t REG_DWORD /d 1 /f
::THIS IS TO SHOW FILE NAME EXTENSIONS
Reg.exe add "HKLM\default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v HideFileExt /t REG_DWORD /d 0 /f
:STOPPING EDGE FROM PRELOADING
REG ADD "HKLM\default\SOFTWARE\Policies\Microsoft\MicrosoftEdge\TabPreloader" /f /v AllowTabPreloading /t REG_DWORD /d 0
REG ADD "HKLM\default\SOFTWARE\Policies\Microsoft\MicrosoftEdge\Main" /f /v AllowPrelaunch /t REG_DWORD /d 0
::THIS DELETES THE ONEDRIVE SETUP FOR NEW USERS BUT SHOULD STILL ALLOW
reg delete "HKLM\default\software\Microsoft\Windows\CurrentVersion\Run" /v OneDriveSetup /f
::THIS REMOVES HOME FROM NAVIGATION
REG ADD "HKLM\default\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" /f /v HubMode /t REG_DWORD /d 1
REG DELETE "HKLM\default\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace_36354489\{f874310e-b6b7-47dc-bc84-b9e6b38f5903}" /f
::THIS SHOWS MORE APPS IN START MENU
REG ADD "HKLM\default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /f /v Start_Layout /t REG_DWORD /d 1
::THIS SHOWS RECENTLY OPENED ITEMS IN START MENU
REG ADD "HKLM\default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /f /v Start_TrackDocs /t REG_DWORD /d 1
::THIS HIDES RECENTLY ADDED APPS IN START MENU
REG ADD "HKLM\default\Software\Policies\Microsoft\Windows\Explorer" /f /v HideRecentlyAddedApps /t REG_DWORD /d 1
::THIS HIDES MOST USED APPS IN START MENU
REG ADD "HKLM\default\Software\Policies\Microsoft\Windows\Explorer" /f /v ShowOrHideMostUsedApps /t REG_DWORD /d 2
::THIS ENABLES THE OLDER STYLE CONTEXTUAL MENUS
reg add "HKLM\default\Software\Microsoft\Windows\CurrentVersion\RunOnce" /v FullContext /d "C:\Windows\system32\cmd.exe /c reg add \"HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32\" /v \"\" /f" /f
::THIS IS TASKBAND FOR ALL USERS
reg add "HKLM\default\Software\Microsoft\Windows\CurrentVersion\RunOnce" /v CustomTaskbandFavorites /d "C:\Windows\system32\cmd.exe /c REG ADD \"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Taskband\" /v Favorites /t REG_BINARY /d \"ff\" /f" /f
reg add "HKLM\default\Software\Microsoft\Windows\CurrentVersion\RunOnce" /v CustomTaskbandFavoritesResolve /d "C:\Windows\system32\cmd.exe /c REG ADD \"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Taskband\" /v FavoritesResolve /t REG_BINARY /d \"\" /f" /f
::THIS IS A TASK TO REBOOT EXPLORER ON FIRST LOGIN
reg add "HKLM\default\Software\Microsoft\Windows\CurrentVersion\RunOnce" /v Restart /d "powershell -Command Stop-Process -Processname Explorer -WarningAction SilentlyContinue -ErrorAction SilentlyContinue -force" /f
::THIS UNLOADS THE DEFAULT HIVE
reg unload HKLM\DEFAULT
答案2
请使用此代码。
Import-Module StartLayout
# Get the list of pinned apps in the Start menu
$apps = Get-StartApps
# Unpin the apps from the Start menu
foreach ($app in $apps) {
$appId = $app.AppId
$packageName = $appId.Split('_')[0]
$packageFullName = (Get-AppxPackage | Where-Object {$_.PackageFamilyName -eq $packageName}).PackageFullName
$shell = New-Object -ComObject Shell.Application
$folder = $shell.Namespace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}')
$item = $folder.Parsename("$packageName!App")
$verb = $item.Verbs() | Where-Object {$_.Name.replace('&', '') -eq 'Unpin from Start'}
$verb.DoIt()
}