> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XLaunchNewGame

> XLaunchNewGame

# XLaunchNewGame

Ends the current game, frees any allocated resources, and launches a new game.

## Syntax

```cpp theme={null}
void XLaunchNewGame(  
         const char* exePath,  
         const char* args,  
         XUserHandle defaultUser  
)  
```

### Parameters

*exePath*   \_In\_z\_\
Type: char\*

The path and file name of the new game to launch. This path can be either relative to the current directory or an absolute path. Games that need to know the path to the calling executable can call [GetModuleFileNameA](https://learn.microsoft.com/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulefilenamea) with a nullptr for the module handle.

*args*   \_In\_opt\_z\_\
Type: char\*

Any applicable, game-specific arguments with which to launch the new game.

*defaultUser*   \_In\_opt\_\
Type: XUserHandle

The handle of the user launching the new game. If a value isn't specified, the current user is
specified.

### Return value

Type: void

This function does not return a value or raise exceptions, even if it's unable to restart the game.

## Remarks

<Note>This function isn't safe to call on a time-sensitive thread. For more</Note>
information, see [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads).

This function restarts the game, ends the game's current process, and restarts the game by using a
new process. The game is restarted without restarting the virtual machine on which the game is
running. You have the option to specify a different default user and game-specific arguments with
which the game is to be restarted; for details on specifying a different default user, see [User
identity and XUser](/build/core-features/common/user/player-identity-xuser).

The current process is always terminated, even if the function encounters an error while launching a
new game. For example, if any value specified for *exePath*, *args*, or *defaultUser* is not valid,
the function does not return a value or raise an exception.

<Note>When this function is called, all previously mounted DLC will get</Note>
unmounted with the exception being the DLC hosting the target of **XLaunchNewGame**. The **G:**
drive will continue to point at the root of the base package and not the newly launched EXE.

<Note>If a game is suspended after **XLaunchNewGame** is called but prior to</Note>
the newly launched game setting up its suspend handler, the game will get terminated. This is a
very narrow window of time and in practice should be a very unlikely occurrence.

<Note>Memory transferred to the system using [XMemTransferMemory (NDA topic)](/reference/system/xmem/functions/xmemtransfermemory) is persisted.</Note>

## Requirements

**Header:** XGame.h

**Library:** xgameruntime.lib

**Supported platforms:** Windows, XBOX One family consoles and XBOX Series consoles

## Conceptual documentation

* [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)
* [Supporting Games-as-a-Service (GaaS)](/build/core-features/common/packaging/supporting-games-as-a-service)

## See also

[XGame](/reference/system/xgame/xgame_members)\
[User identity and XUser](/build/core-features/common/user/player-identity-xuser)\
[XLaunchUri](/reference/system/xlauncher/functions/xlaunchuri)


## Related topics

- [XLaunchRestartOnCrash](/reference/system/xgame/functions/xlaunchrestartoncrash.md)
- [XGame](/reference/system/xgame/xgame_members.md)
- [Changing the Default User for the Game](/build/core-features/common/user/users-changing-default-user.md)
- [Supporting Games-as-a-Service (GaaS)](/build/core-features/common/packaging/supporting-games-as-a-service.md)
- [Users and input devices](/build/core-features/common/user/users-input-devices.md)
