A long-awaited feature has come to Universal Windows programming; i.e.; the ability to programmatically restart the application. Previously we had to inform to the user with a prompt (like Message Dialog) to close and relaunch the application. Now relaunch is not required from the user side.
This article explains about how to implement this feature into our application.
Note
This API will be support Windows Insider Build version 16257 or greater, public version will be available on 17-Oct-17 (windows 10 fall creators update version) onwards
System Requirements
- Windows 10 Insider Build 16257 or greater
- Windows 10 16257 SDK
- Visual Studio 2017
RequestRestartAsync & RequestRestartForUserAsync API
RequestRestartAsync & RequestRestartForUserAsync is used to Restart the application, this API is available in CoreApplication class
- CoreApplication.RequestRestartAsync(string launchArguments)
- CoreApplication. RequestRestartForUserAsync (User user,string launchArguments)
launchArguments
This argument is used to pass the information to the Restart Instance. Let see one simple example, how to restart the application programmatically and read the launchArguments in the new Instance
Open VisualStudio -> File -> Visual C# -> Windows Universal -> Blank App(Universal Windows)

- <Page
- x:Class="App1.MainPage"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:local="using:App1"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- mc:Ignorable="d">
- <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="10,10,10,10">
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto"/>
- <RowDefinition Height="Auto"/>
- <RowDefinition Height="Auto"/>
- </Grid.RowDefinitions>
- <TextBlock Name="TxtStatus" Grid.Row="0" Text="" FontSize="25" TextWrapping="WrapWholeWords"/>
- <Button Grid.Row="1" Content="Restart" Click="ButtonBase_OnClick" Margin="10,10,10,10"></Button>
- </Grid>
- </Page>
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Runtime.InteropServices.WindowsRuntime;
- using Windows.ApplicationModel.Activation;
- using Windows.ApplicationModel.Core;
- using Windows.Foundation;
- using Windows.Foundation.Collections;
- using Windows.System;
- using Windows.UI.Popups;
- using Windows.UI.Xaml;
- using Windows.UI.Xaml.Controls;
- using Windows.UI.Xaml.Controls.Primitives;
- using Windows.UI.Xaml.Data;
- using Windows.UI.Xaml.Input;
- using Windows.UI.Xaml.Media;
- using Windows.UI.Xaml.Navigation;
- // The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
- namespace App1
- {
- /// <summary>
- /// An empty page that can be used on its own or navigated to within a Frame.
- /// </summary>
- public sealed partial class MainPage : Page
- {
- public MainPage()
- {
- this.InitializeComponent();
- TxtStatus.Text = "Restart Application Sample";
- if (ReadAppData.ArgInfo != null)
- TxtStatus.Text = ReadAppData.ArgInfo;
- }
- private async void ButtonBase_OnClick(object sender, RoutedEventArgs e)
- {
- var result = await CoreApplication.RequestRestartAsync("Application Restart Programmatically ");
- if (result == AppRestartFailureReason.NotInForeground ||
- result == AppRestartFailureReason.RestartPending ||
- result == AppRestartFailureReason.Other)
- {
- var msgBox = new MessageDialog("Restart Failed", result.ToString());
- await msgBox.ShowAsync();
- }
- }
- }
- }
RequestRestartForUserAsync (User user, string launchArguments)

Vikram KalalPosted Apr 27, 2021, 10:18 AM
App not restart in release mode
pranav sagarPosted Jan 25, 2021, 6:04 AM
Thanks for the article, is there any way to detect if the restart API is supported on a particular system or not? I mean can we check the build version and get the information?