- Save the
disable-program-reopen.ps1file below to a directory on your computer, such as%SYSTEMROOT%\System32\GroupPolicy\User\Scripts\Logon. - Allow unsigned local PowerShell scripts to run on your computer.
- Open PowerShell as an administrator.
- Run the following command and answer
Ywhen it prompts you.Set-ExecutionPolicy RemoteSigned
- Set a Group Policy to run this script when users log on.
- Open the Local Group Policy Editor (
gpedit.msc, or search for Group Policy in the Start Menu). - Go to User Configuration → Windows Settings → Scripts (Logon/Logoff) → Logon.
- In the PowerShell Scripts tab, choose Add…
- Select the
disable-program-reopen.ps1file that you downloaded.
- Open the Local Group Policy Editor (
- When Windows shuts down, it saves the user's running programs to the
RunOnceregistry key so they will reopen upon reboot. - Each applicable program is added as a value to
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOncewith a name likeApplication Restart #0and string data containing the absolute path of the executable file. - This script runs before the
RunOncekey is read, because Group Policy logon scripts run beforeRunandRunOnce. - This script finds all values in the
RunOncekey whose name start withApplication Restart #and deletes them. It leaves all other values unchanged. - Windows Explorer reads the
RunOncekey and launches each of the programs. - Since the
RunOncelist already had all of the running programs from the previous Windows session deleted, Windows Explorer does not relaunch them.
Microsoft added an official option to toggle this behavior. It seems to have been released with Windows 10 version 1803.
- Go to Settings → Accounts → Sign-in options.
- Under Privacy, disable "Use my sign-in info to automatically finish setting up my device and reopen my apps after an update or restart".
Unfortunately, many users report that the option is not present for them. Some editions of Windows don't include this option, including Windows 10 Enterprise, Windows Server 2016 (1607), and Windows Server 2019 (1809). For these operating systems, the group policy script below is still the way to go.