Creating a service using Powershell in C#

Currently I am modifying the C#/Powershell-project for NAV-Services from the MS Dynamics NAV Team Blog.
(http://blogs.msdn.com/b/nav/archive/2011/09/19/using-powershell-to-configure-dynamics-nav-services.aspx)

While adding some more functionality I realized that it is not quite easy to create new services on a remote computer using powershell.
After some days of searching and testing I succeded using this small piece of code. (It is based on the linked project)

private void btn_CreateService_Click(object sender, EventArgs e)
{
    string StartType = "Manual";
    string DefinitionScript = "$service = [wmiclass]('\\" + ComputerName + @"\ROOT\CIMV2:Win32_Service')";
    string Script = "$service.Create("+txtName.Text+","+txtDisplay.Text+","+txt_ApplicationPath.Text+",16,0,"+StartType+",'false')";

    using (Runspace runSpace = RunspaceFactory.CreateRunspace())
    {
        runSpace.Open();
        Pipeline pipeLine = runSpace.CreatePipeline();
        pipeLine.Commands.AddScript(DefinitionScript);
        pipeLine.Commands.AddScript(Script);
        pipeLine.Invoke();
    }
}

See this MSDN-article for definition of parameters and other StartTypes.