/build/static/layout/Breadcrumb_cap_w.png

Windows 11 Start Menu Pin Customization

Hello! I've been scratching my head on this one and maybe just making it more complicated than it needs to be. Basically I have a start.bin file that I want to copy to each user profile that logs in to reset the start menu pins to be custom ones I have set up. The program works, it runs through group policy at logon. It fixes the initial account that I use to set up the image, but any other users that log in seem to already have the file that the .ps1 file checks for, therefore making the program not run and fix their start menu. Hopefully this makes sense. Here's the code that I wrote:

if (Test-Path -Path $env:SystemDrive\Layouts\User_Start-Menus'\Delete2ResetStartMenu_'$env:USERNAME.txt'')

{

##do nothing if file already exists

        exit

}

else

{

##overwrites start.bin to set up custom start menu for each user

Copy-Item -Path $env:SystemDrive\Layouts'\start.bin' -Destination $env:SystemDrive'\Users\'$env:username'\AppData\Local\Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState'


##restarts start menu

Stop-Process -Name "StartMenuExperienceHost" -Force

##create file to complete if loop statement

New-Item $env:SystemDrive\Layouts\User_Start-Menus'\Delete2ResetStartMenu_'$env:USERNAME.txt''

}


So, in theory, it checks under a folder in the C: drive, if the file isn't there, it resets the start menu pins. If the file is there, it does nothing. That way people can save new pins to the menu so long as that file exists. The code actually was a little more simple before but I've been trying different variations to try to make it work as cleanly as possible. When I log on as a new user, the file that is supposed to be created exists already, so the program just doesn't do anything. If I delete the file, log out, log back in, then it will fix my start menu and then proceed to work correctly from there. So I'm not sure if there's something I'm missing with the setup or how the user account is being created that's maybe resetting my pins after the program runs in group policy? I hope this makes sense. Thanks for the help!


0 Comments   [ + ] Show comments

Answers (2)

Answer Summary:
Posted by: ncunning3 2 months ago
Senior White Belt
0

In case anyone is ever interested here is my solution I've come up with so far:


I created a .ps1 file titled StartMenu-Fix.ps1. This file is being stored in the main account used to set up the image under the Users>[username]\Layouts folder. Inside that folder is another folder titled StartMenuFiles. The StartMenu-Fix.ps1 file contains the following code:


##If Delete2ResetStartMenu_username.txt exists in the user drive

if (Test-Path -Path $env:SystemDrive\Users\$env:username'\Layouts\StartMenuFiles\Delete2ResetStartMenu_'$env:username.txt'')

{

    exit

}


##Copy start.bin, create Delete2ResetStartMenu_username.txt to stop program from running again

else

{

    ##overwrites start.bin to set up custom start menu

    Copy-Item -Path $env:SystemDrive\Users\$env:username\Layouts'\start.bin' -Destination $env:SystemDrive'\Users\'$env:username'\AppData\Local\Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState'


    ##restarts start menu

    Stop-Process -Name "StartMenuExperienceHost" -Force


    ##create file to complete if loop statement

    New-Item $env:SystemDrive\Users\$env:username'\Layouts\StartMenuFiles\Delete2ResetStartMenu_'$env:username.txt''

    

    exit

}


The start.bin file I copied from my default profile after it was set the way I wanted it to be.There were a few catches I ran into getting this to work. Which is why specifically the file is saved with the username attached. I was getting issues where the file would get created during start up, but then the start menu would get set to default after the code ran. At first I ran it in task scheduler, but had trouble with imaging. So I ran it at logon in group policy. This gave me issues because of the weird way Windows was setting up new users. So, to bypass and fix this, the script now is run in Group Policy at Logoff. The first time a user logs in they won't get the new start menu pins, but after logging in a second time they will. The file saved in the user folder makes it so they can customize their start menu after the second log on and it won't be overwritten by the code. The only other thing worth noting is that in Group Policy I have it tied to C:>Users>%username% to keep things clean and working smoothly.


Maybe this will help someone else? If anyone has any suggestions on making this work better I am open to ideas! 

Posted by: ncunning3 2 months ago
Senior White Belt
0

Top Answer

Update code after 22H2:

##If Delete2ResetStartMenu_username.txt exists in the user drive

if (Test-Path -Path $env:SystemDrive\Users\$env:username'\Layouts\StartMenuFiles\Delete2ResetStartMenu_'$env:username.txt'')

{

    exit

}else {

##Copy start.bin, create Delete2ResetStartMenu_username.txt to stop program from running again


    ##overwrites start.bin to set up custom start menu

    Copy-Item -Path $env:SystemDrive\Users\$env:username\Layouts'\start.bin' -Destination $env:SystemDrive'\Users\'$env:username'\AppData\Local\Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState'


    ##overwrites start2.bin to set up custom start menu

    Copy-Item -Path $env:SystemDrive\Users\$env:username\Layouts'\start2.bin' -Destination $env:SystemDrive'\Users\'$env:username'\AppData\Local\Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState'


    ##restarts start menu

    Stop-Process -Name "StartMenuExperienceHost" -Force


    ##create file to complete if loop statement

    New-Item $env:SystemDrive\Users\$env:username'\Layouts\StartMenuFiles\Delete2ResetStartMenu_'$env:username.txt''

    

    exit

}

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ