Passing command line arguments to VirtualUI appsNew here? Read more about why software developers are adopting Thinfinity VirtualUI to run desktops apps in the cloud and increase the value of their Windows applications.

Any application web-enabled by VirtualUI can accept command-line arguments when invoked. This allows the user to send additional information to the application when it is executed.
When an application is launched, the OS passes the command line arguments to the application as a collection of string values, using a single white space as a separator.

Applications receive external arguments on a regular basis: when you open a document by clicking on its icon, the OS selects the associated executable program and calls it, sending the full document filename to the program as an argument.
Thinfinity VirtualUI allows you to send external arguments to applications in a transparent way, which works exactly like sending arguments from the command line.

Setting command line arguments in the application profile

Thinfinity VirtualUI enables external argument definition from the VirtualUI Server Manager. When you create an application profile, you can specify the execution arguments in the General tab panel of the Application Profiles editor.


These arguments will be received by the application as a list of string values, using the white-space character as argument delimiter.

application profile arguments

In Delphi you can get command line arguments using the System.ParamCount and System.ParamStr methods. ParamCount returns the number of arguments, and ParamStr(index) returns each argument, with ParamStr(0) always being the path and name of the invoked program. Here is a way you can show the received arguments list:

  Writeln(Format(‘Arguments = %d’, [ParamCount]))
  for p := 1 to ParamCount do
    Writeln(Format(‘argument %d = “%s”’, [p, ParamStr(p)]);

In C++, both the argument counter and the argument list will be received in the two main() function arguments. Like in Delphi, the first argument in the string array is the path and name of the program itself:

void main(int argCounter, char* arguments[]) {
  cout << "Arguments = " << argCounter << endl;
  for(int i = 1; i < argCounter; i++)
  cout << "arguments[" << i << "] = " << arguments[i] << endl;

You can also write the main function header in this way:

void main(int argCounter, char** arguments) { … }

Unlike Delphi and C++, C# excludes the name and path of the program from the arguments collection. Also, C# offers two ways to get the arguments, by using a traditional for…

public static void Main(string[] arguments)
    Console.WriteLine("Arguments = {0}", args.Length);
    for(int i = 0; i < arguments.Length; i++)
        Console.WriteLine("Arguments[{0}] = [{1}]", i, arguments[i]);

or by using the foreach:

foreach(string s in arguments)


Sending command line arguments to the application in the VirtualUI url

VirtualUI allows you to send external arguments in the url. Instead of passing static arguments from the application profile definition, using this feature you can send dynamic application arguments in a simple way. The only requirement to be met is that the arguments must be url encoded.

To build the url you need:

  • The communication protocol (http or https).
  • The Thinfinity VirtualUI server domain or IP address, and port.
  • The application virtual path.

Build the url like this:


As an example, we will send the “one”, “two” and “three” argument values to the TestArguments program:

The following image shows the submit result:

URL passed arguments

Building the URL in Javascript

When necessary, modern browsers encode URLs automatically, but it is convenient to do it by code. The Javascript lines below show how to build the URL used in the previous example:

var buildURL = function(server, virtualpath, arguments) {
  return server + “/” + virtualpath + “/?” + encodeURIComponent(arguments.join(‘ ‘));
var baseURL = “”;
var applicationPath = “TestArguments”;
var arguments = [“one”, “two”, “tree”];
var url = buildURL(baseURL, applicationPath, arguments);


Combining both application profile and url command line arguments

If you have defined command line arguments in the application profile and need to send new arguments to the application by url, don’t worry. Thinfinity VirtualUI merges both argument lists, first adding the application profile arguments, and then the arguments that were passed in the URL.

merged command-line arguments
Quick Tip: Review the most recent articles about Thinfinity VirtualUI.

Have any questions? Contact us at [email protected] or leave a message on this same post.


Thinfinity Solutions for remote desktop, screen sharng, digital workspace and application virtualization.

Thinfinity Solutions

As you already know, Thinfinity VirtualUI is a web-enabling SDK to run apps on a browser without rewriting the code.

Explore our other remoting and web-enabling solutions, enjoy our free trials, or request a custom demo HERE. No commitment!

We will be happy to assist you and show you our portfolio for remote desktop, screen sharing, digital workspace, and application virtualization.

Leave a comment