# Can we make command line arguments?

**URL:** <https://forums.unrealengine.com/t/can-we-make-command-line-arguments/297291>\
**Category:** Blueprint\
**Tags:** command-line-argumen, command-line, unreal-engine, Blueprint, question, CPP\
**Created:** [October 26, 2014, 4:23pm UTC](https://forums.unrealengine.com/t/can-we-make-command-line-arguments/297291 "2014-10-26T16:23:05Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon90101103](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anon90101103](https://forums.unrealengine.com/u/anon90101103)\
**Post date:** [October 26, 2014, 4:23pm UTC](https://forums.unrealengine.com/t/can-we-make-command-line-arguments/297291/1 "2014-10-26T16:23:05Z")

</div>

Hello there, I would like to add a new command line argument to my game that enables a special mode, is there any way that I can create a new one without needing to modify the engine?

Greetings.

---

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [October 26, 2014, 4:57pm UTC](https://forums.unrealengine.com/t/can-we-make-command-line-arguments/297291/2 "2014-10-26T16:57:59Z")

</div>

#Yes

try running this anywhere

```
if(FParse::Param(FCommandLine::Get(), TEXT("MyFlagPresent")))
{
  //UE_LOG or Printstirng "My flag was present in the commandline!" ;
}

```

and run the game with

-MyFlagPresent

#❤

Rama

---

<div class="post-metadata">

**Author:** ![anon90101103](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anon90101103](https://forums.unrealengine.com/u/anon90101103)\
**Post date:** [October 26, 2014, 6:39pm UTC](https://forums.unrealengine.com/t/can-we-make-command-line-arguments/297291/3 "2014-10-26T18:39:41Z")

</div>

Just what I needed, thanks!

But what about getting parameters after flags?

like -MyFlagPresent 1

---

<div class="post-metadata">

**Author:** ![blurdot](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@blurdot](https://forums.unrealengine.com/u/blurdot)\
**Post date:** [November 14, 2014, 6:20pm UTC](https://forums.unrealengine.com/t/can-we-make-command-line-arguments/297291/4 "2014-11-14T18:20:24Z")

</div>

Just what I needed, thanks!

```
But what about getting parameters after flags?

like -MyFlagPresent 1

```

I would love to know this answer as well.

---

<div class="post-metadata">

**Author:** ![RichardB](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RichardB](https://forums.unrealengine.com/u/RichardB)\
**Post date:** [March 20, 2015, 8:26am UTC](https://forums.unrealengine.com/t/can-we-make-command-line-arguments/297291/5 "2015-03-20T08:26:31Z")

</div>

Hi, you’ve probably already found the answer to this, but in case anyone else is looking, having a look at Parse.h gives the clue: you can use the “Value” method of FParse, eg:

```
 int32 val;
  if(FParse.Value(FCommandLine::Get(), TEXT("MyFlagPresent"),val)) {

      blah
  }

```

Also, you can manually parse the string returned by FCommandLine::Get().

---

<div class="post-metadata">

**Author:** ![Omberone](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Omberone](https://forums.unrealengine.com/u/Omberone)\
**Post date:** [June 18, 2015, 4:45pm UTC](https://forums.unrealengine.com/t/can-we-make-command-line-arguments/297291/6 "2015-06-18T16:45:44Z")

</div>

Same here. Works for me when using standard exe, but not on my server.exe.

---

<div class="post-metadata">

**Author:** ![fishhead2567](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@fishhead2567](https://forums.unrealengine.com/u/fishhead2567)\
**Post date:** [July 23, 2015, 7:05pm UTC](https://forums.unrealengine.com/t/can-we-make-command-line-arguments/297291/7 "2015-07-23T19:05:43Z")

</div>

Since there was no answer chosen and a few comments, here is an example of what I used to do this. To do strings, I have to do -param=“STRING”, so I need the quotes and the equals sign. Here is a sample command and tthe code that pareses it.

**EDIT:** I noticed I forgot to strip the = sign.

mygame.exe -skinByClass -startPose 2 -scb="\pathtoafile"

```
FString fileName;
uint32 startPose;

//string
if (FParse::Value(FCommandLine::Get(), TEXT("scb"), fileName)) {
	fileName = fileName.Replace(TEXT("="), TEXT("")).Replace(TEXT("\""), TEXT("")); // replace quotes
	_SCBFile = fileName;
}

//integer
if (FParse::Value(FCommandLine::Get(), TEXT("startPose"), startPose)) {
	_startPose = startPose;
}

//boolean
if (FParse::Param(FCommandLine::Get(), TEXT("skinByClass"))) {
	_skinByClass = true;
}
```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_01dd28a6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_01dd28a6](https://forums.unrealengine.com/u/anonymous_user_01dd28a6)\
**Post date:** [August 14, 2015, 4:29am UTC](https://forums.unrealengine.com/t/can-we-make-command-line-arguments/297291/8 "2015-08-14T04:29:16Z")

</div>

My Solution

```
The .h file....

	UFUNCTION(BlueprintCallable, Category = TDLHelpers)
		static bool CommandLineArgPresent(FString key = "unknown");
	UFUNCTION(BlueprintCallable, Category = TDLHelpers)
		static FString CommandLineArgValue(FString key = "unknown", FString defaultValueIfAbsent = "empty");
	UFUNCTION(BlueprintCallable, Category = TDLHelpers)
		static int32 CommandLineArgIntValue(FString key = "unknown", int32 defaultValueIfAbsent = 0);

and in the .cpp file...

bool UtdlBlueprintHelpers::CommandLineArgPresent(FString key)
{
	return FParse::Param(FCommandLine::Get(), *key);
}

FString UtdlBlueprintHelpers::CommandLineArgValue(FString key, FString defaultValueIfAbsent)
{
	FString s;

	if (FParse::Value(FCommandLine::Get(), *key, s)) {
		return s;
	}

	return defaultValueIfAbsent;
}

int32 UtdlBlueprintHelpers::CommandLineArgIntValue(FString key, int32 defaultValueIfAbsent)
{
	int32 i;

	if (FParse::Value(FCommandLine::Get(), *key, i)) {
		return i;
	}

	return defaultValueIfAbsent;
}

```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0cc0891d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0cc0891d](https://forums.unrealengine.com/u/anonymous_user_0cc0891d)\
**Post date:** [March 5, 2017, 12:01pm UTC](https://forums.unrealengine.com/t/can-we-make-command-line-arguments/297291/9 "2017-03-05T12:01:37Z")

</div>

hello，i am a new programer ,i don’t know how to use Command-Line Arguments,can you tell me? thank you very much!!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_f77a82de](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_f77a82de](https://forums.unrealengine.com/u/anonymous_user_f77a82de)\
**Post date:** [May 27, 2017, 9:48pm UTC](https://forums.unrealengine.com/t/can-we-make-command-line-arguments/297291/10 "2017-05-27T21:48:49Z")

</div>

This is actually really strange. The way they present command lines but in game…Their should be a library

---

<div class="post-metadata">

**Author:** ![Stormwind](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Stormwind](https://forums.unrealengine.com/u/Stormwind)\
**Post date:** [July 18, 2017, 8:52pm UTC](https://forums.unrealengine.com/t/can-we-make-command-line-arguments/297291/11 "2017-07-18T20:52:06Z")

</div>

We have a small plugin to access command line parameters from Blueprint: [GitHub - DescendentStudios/CommandLineParametersPlugin: Plugin for Unreal Engine 4 (UE4) to access command line from Blueprint](https://github.com/DescendentStudios/CommandLineParametersPlugin)

---

<div class="post-metadata">

**Author:** ![Vaei](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/vaei/32/710746_2.png) [@Vaei](https://forums.unrealengine.com/u/Vaei)\
**Post date:** [January 6, 2018, 12:46am UTC](https://forums.unrealengine.com/t/can-we-make-command-line-arguments/297291/12 "2018-01-06T00:46:26Z")

</div>

For future googlers like myself

**This is the correct answer**

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_05cc32921](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_05cc32921](https://forums.unrealengine.com/u/anonymous_user_05cc32921)\
**Post date:** [May 29, 2018, 12:47am UTC](https://forums.unrealengine.com/t/can-we-make-command-line-arguments/297291/13 "2018-05-29T00:47:59Z")

</div>

Do you know how can I get string parameter including “,”? FParse::Value(FCommandLine::Get(), TEXT(“scb”), fileName) get just before “,”.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b6ef1c01](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b6ef1c01](https://forums.unrealengine.com/u/anonymous_user_b6ef1c01)\
**Post date:** [September 17, 2018, 12:02pm UTC](https://forums.unrealengine.com/t/can-we-make-command-line-arguments/297291/14 "2018-09-17T12:02:15Z")

</div>

where shall i add this code? i need to add a boolean check for the user which will run a specific code block in the client\_example.py

---

<div class="post-metadata">

**Author:** ![Weibye](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Weibye](https://forums.unrealengine.com/u/Weibye)\
**Post date:** [January 3, 2019, 10:58am UTC](https://forums.unrealengine.com/t/can-we-make-command-line-arguments/297291/15 "2019-01-03T10:58:38Z")

</div>

If using command line parameters like this:

```
-ParamBool -ParamInt 3 -ParamValue="MyTextValue"

```

then a quick removal of the = sign is necessary.

```
 FString UtdlBlueprintHelpers::CommandLineArgValue(FString key, FString defaultValueIfAbsent)
 {
     FString s;
 
     if (FParse::Value(FCommandLine::Get(), *key, s)) {
         return s.Replace(TEXT("="), TEXT(""));
     }
 
     return defaultValueIfAbsent;
 }
```

---

<div class="post-metadata">

**Author:** ![MadSystem](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MadSystem](https://forums.unrealengine.com/u/MadSystem)\
**Post date:** [May 23, 2019, 2:10pm UTC](https://forums.unrealengine.com/t/can-we-make-command-line-arguments/297291/16 "2019-05-23T14:10:39Z")

</div>

You can also just put the “=” into the parser function so you don’t need to modify the string later on.

```
FString GameModeArg;
if (FParse::Value(FCommandLine::Get(), TEXT("-gamemode="), GameModeArg))
{
GameMode = GameModeArg;
}
```
