# Running Game Engine from Command Line

**URL:** <https://blenderartists.org/t/running-game-engine-from-command-line/558919>\
**Category:** Game Engine Support and Discussion\
**Created:** [December 7, 2012, 5:59pm UTC](https://blenderartists.org/t/running-game-engine-from-command-line/558919 "2012-12-07T17:59:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ejang](https://blenderartists.org/user_avatar/blenderartists.org/ejang/32/12151_2.png) [@ejang](https://blenderartists.org/u/ejang)\
**Post date:** [December 7, 2012, 5:59pm UTC](https://blenderartists.org/t/running-game-engine-from-command-line/558919/1 "2012-12-07T17:59:52Z")

</div>

Hello,

I apologize if another newbie has asked this already, but I was wondering if it’s possible to run the Game Engine from the command line using bge.logic.startGame()

I attempted to do ./blender -P script.py,

where script.py is as follows:

```auto
import bge
bge.logic.startGame()

```

Of course, this does not work as bge is only available whilst the game engine is running.

Any suggestions?

Thanks!

---

<div class="post-metadata">

**Author:** ![SolarLune](https://blenderartists.org/user_avatar/blenderartists.org/solarlune/32/7258_2.png) [@SolarLune](https://blenderartists.org/u/SolarLune)\
**Post date:** [December 7, 2012, 7:19pm UTC](https://blenderartists.org/t/running-game-engine-from-command-line/558919/2 "2012-12-07T19:19:44Z")

</div>

If you want to start a BGE game from the command line, use the BlenderPlayer. If you want to start a BGE game as soon as you open the blend file via Blender, the only real way is to set it to Auto-start from the game menu. Note, though, that doing this causes the blend to immediately start the game engine, so your game will be in a lock if you save it after turning Auto-start on.

---

<div class="post-metadata">

**Author:** ![agoose77](https://blenderartists.org/user_avatar/blenderartists.org/agoose77/32/442949_2.png) [@agoose77](https://blenderartists.org/u/agoose77)\
**Post date:** [December 8, 2012, 7:04am UTC](https://blenderartists.org/t/running-game-engine-from-command-line/558919/3 "2012-12-08T07:04:26Z")

</div>

Actually, You could call the operator to launch the game engine using a script.  
Import the bpy module and somewhere there will be an operator.

---

<div class="post-metadata">

**Author:** ![agoose77](https://blenderartists.org/user_avatar/blenderartists.org/agoose77/32/442949_2.png) [@agoose77](https://blenderartists.org/u/agoose77)\
**Post date:** [December 9, 2012, 3:40am UTC](https://blenderartists.org/t/running-game-engine-from-command-line/558919/4 "2012-12-09T03:40:03Z")

</div>

Yes, it seems you cannot call that operator from the commandline, as there is no context to work from. Your best bet would be enabling autostart, or using BlenderPlayer
