The term dcpromo is not recognized as the name of cmdlet, function, scriptfile or operable program. Check the spelling of the name or if the path was included, verify that the path is correct and try again. Cannot bind argument to parameter 'FilePath' because it is null.

I don't understand why is it not able to recognize 'dcpromo'.
I am able to run the same command manually in powershell on WIndows Server 2008 R2. Howeever when I run this through a primal form project, I am getting the error.

I have also tried Invoke-Command, start-process, calling another ps1\cmd file to run the dcpromo commmand, but it keeps giving same error saying dcpromo not recognized.

If this is a cmdlet from a module or snapin, be sure to explicitly load it within your script, because PrimalForms does not load profiles. PF 2011 only supports PowerShell V2, so if the module or snapin is requires V3 or greater, it will not work at all.

Ok I see, Dcpromo is an external executable and not a cmdlet or alias. Most likely the problem is that dcpromo is 64 bit and PrimalForms is a 32 bit application, therefore it doesn't find the executable when running the script.

Dcpromo is used to promote a server as a Domain Controller and the same command is used to demote the domain controller with different arguments.
The promotion of Domain Controller using primal Forms 2011 is working fine however the demotion is not working.

If Primal Forms cannot recognize 64 bit exe, I'm wondering how is it able to promote the server using same 'Dcpromo' command?

I'm using the exact same method to demote which is used for promotion.

If it does, then you have an access or rights problem.
If that gives you the same error then your code is different for demoting than from promoting.

If you substitute notepad.exe and still get the "The term dcpromo is not recognized as ..." error, then you are looking at the wrong code.

Since we don't see your script it's hard to judge, but usually that would call for using a debugger, set a breakpoint and examine the variables at the location and follow the program logic to see if you even hit the right spot.