I am trying to execute a console app with arguments inside asp.net (C#) on Windows XP. I have tried diagnostics.Process but I just can’t get it to work so I am switching to CreateProcessWithLogonW. I used the code sample from http://www.pinvoke.net/default.aspx/advapi32.createprocesswithlogonw but the console app doesn’t seem to run and the return value from the CreateProcessWithLogonW api call is false.
My console app syntax is like: “C:\Program Files\business Intelligence\mycommand.exe” arg1 arg2 arg3 arg4 which runs fine if I run it interactively in a dos window.
In the C# code I am adding the double quotes before and after the program name. When the code runs I noticed that the task manager processes count didn’t increase ath the second I run it which tells me the app didn’t run. The processInfo structure has all 0’s.
My questions:
1- Do the two ‘command’ parameters for the ‘CreateProcessWithLogonW’ call need to have the double quotes? Right now I am putting the whole command line in each.
2- How do I capture the standard Output so I know what has happened?
This post worked for me.
http://blogs.msdn.com/alejacma/archive/2007/12/20/how-to-call-createprocesswithlogonw-createprocessasuser-in-net.aspx