--disable-features=RestoreLastSession when launching Microsoft Edge from a batch script to prevent the browser from displaying the restore pages option. This flag forces Edge to start with a clean session, ignoring any previous browsing data that would otherwise trigger the recovery prompt upon launch.
Understanding the Restore Pages Feature
Microsoft Edge includes a convenience feature designed to help users recover their browsing session after an unexpected shutdown or crash. When this feature is active, the browser checks for "last session" data and presents a dialog asking if you want to reopen the tabs you had open previously. While useful for accidental closures, this behavior can be disruptive in automated environments such as scheduled tasks or kiosk mode setups where a fresh, predictable state is required.
The core issue arises because Edge treats every launch as a potential recovery opportunity by default. Even if you close all windows properly, residual session data may remain in the user profile directory. Consequently, the next time the executable runs, it detects this data and interrupts the startup process with the restore UI. To bypass this, we must explicitly instruct the browser engine to ignore these recovery signals during initialization.
Why Standard Methods Fail
Simply closing all Edge windows before running your script does not guarantee that the restore prompt will disappear. The browser stores session state in specific registry keys and local storage folders within the user profile. Unless these are cleared manually or the browser is launched with specific flags, the internal logic assumes a session recovery is needed. Therefore, relying on timing delays or window management techniques in your batch file is unreliable and inefficient.
Creating the Batch Script
To solve this problem programmatically, you need to construct a command that calls the Edge executable directly rather than using the standard start command without parameters. The most robust method involves specifying the full path to the msedge.exe binary and appending the necessary feature disable flag. This approach ensures that the setting applies regardless of how the user normally launches the browser.
@echo off
REM Define the URL you wish to open
set URL=https://www.example.com
REM Define the path to Edge executable
set EDGE_PATH="C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
REM Launch Edge with the disable-features flag
%EDGE_PATH% --disable-features=RestoreLastSession %URL%
In this script, the @echo off directive keeps the console window clean from verbose output. We define variables for the target URL and the executable path to make the script easily modifiable. The critical component is the argument passed to msedge.exe. By including --disable-features=RestoreLastSession, we tell the Chromium-based engine to skip the check for last-session data entirely. This results in a silent launch that navigates directly to the specified URL without any interactive prompts.
Integrating with Scheduled Tasks
When deploying this solution via Windows Task Scheduler, additional considerations apply. Scheduled tasks often run under different user contexts or with minimal privileges compared to an interactive desktop session. It is crucial to ensure that the task is configured to run whether the user is logged on or not, if background execution is desired, though launching a GUI application like Edge typically requires an interactive session.
You should configure the action in Task Scheduler to start a program, pointing to the same msedge.exe path used in the batch file. Alternatively, you can point the scheduler directly to the batch file created above. Ensure that the "Start in" field is set to a valid directory, preferably the folder containing the script or the system32 directory, to avoid relative path resolution errors. If you encounter issues with the script failing to launch, verify that the account running the task has permission to execute binaries in the Program Files directory.
Troubleshooting Common Issues
If the restore prompt still appears despite using the flag, consider the following diagnostic steps. First, verify that you are using the correct version of Edge. The 64-bit version resides in C:\Program Files\Microsoft\Edge\Application\msedge.exe, while the older 32-bit version is in (x86). Using the wrong path might cause the command to fail silently or launch a different browser entirely.
Secondly, check for conflicting arguments. Some enterprise policies enforced by Group Policy Object (GPO) might override command-line flags. If your organization manages browser settings centrally, the policy might force session restoration regardless of user-level commands. In such cases, you may need to consult your IT administrator or use the article on How to Disable Microsoft Edge Restore Pages Functionality to understand policy overrides.
Additionally, ensure that no other instances of Edge are running in the background. Sometimes, a hidden process holding onto session locks can interfere with new launches. Closing all Edge processes via Task Manager before testing your script can help isolate whether the issue is related to session persistence or command-line parsing.
Alternative Approaches
If modifying the Edge launch command is not feasible due to strict environment constraints, another option is to clear the session data before launching. This can be done by deleting specific files in the Edge user data folder, but this method is fragile and risky as it may delete cookies and preferences unintentionally. A safer alternative is to use a different browser for automation purposes, such as Google Chrome with similar flags, or a headless browser like Puppeteer if JavaScript execution is required.
For simple webpage opening tasks, you might also consider using PowerShell instead of Batch. PowerShell offers more robust error handling and can interact with COM objects to control browsers more precisely. However, for straightforward navigation without complex interaction, the Batch method remains the most lightweight and compatible solution across various Windows versions.
Frequently Asked Questions
Does this flag delete my browsing history?
No, the --disable-features=RestoreLastSession flag only prevents the browser from reopening tabs from the previous session. It does not affect your existing history, cookies, passwords, or bookmarks. Your browsing data remains intact in the user profile directory.
Can I use this flag with other Chromium browsers?
While many Chromium-based browsers share similar architecture, the specific flag name may vary. For example, Brave or Opera might handle session restoration differently. You should test the flag in each browser individually, as some may require --no-first-run or other specific parameters to achieve similar results.
What happens if Edge crashes while this flag is active?
If Edge crashes unexpectedly, the session recovery feature will still be disabled for the subsequent launch. This means you will lose the tabs that were open during the crash, and they will not be automatically restored. This trade-off is necessary to ensure a clean startup state for automated scripts.
How do I find the exact path to msedge.exe?
You can locate the executable by searching for "Microsoft Edge" in the Windows Start menu, right-clicking the shortcut, selecting "Properties," and copying the "Target" field. Alternatively, check the standard installation directories: C:\Program Files\Microsoft\Edge\Application\msedge.exe for 64-bit or C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe for 32-bit.
Will this work in Kiosk Mode?
Yes, this flag is compatible with Kiosk Mode. In fact, it is highly recommended for kiosk setups to prevent unpredictable behavior caused by session restoration prompts. Combining this flag with the --kiosk parameter ensures a seamless, full-screen experience without interruptions.