C# Process UseShellExecute query
-
I got a simple HelloWorld.Exe that prints out helloworld And I got another application that wants to process that exe file, store as a string and the reprint hello world, called "ReadHelloWorld.exe" But I find that use the property from Process "UseShellExecute" when turned false, is that the Working directory I set to wont be used, so I can only execute HelloWorld.exe within ReadHelloWorld.exe. Is there a way such that I can use the Process to store it as a string without resorting to using a shell to execute the command, store it as a text file, read its contents then removing the temporary text file? Kuira
-
I got a simple HelloWorld.Exe that prints out helloworld And I got another application that wants to process that exe file, store as a string and the reprint hello world, called "ReadHelloWorld.exe" But I find that use the property from Process "UseShellExecute" when turned false, is that the Working directory I set to wont be used, so I can only execute HelloWorld.exe within ReadHelloWorld.exe. Is there a way such that I can use the Process to store it as a string without resorting to using a shell to execute the command, store it as a text file, read its contents then removing the temporary text file? Kuira
Kuira wrote:
Is there a way such that I can use the Process to store it as a string without resorting to using a shell to execute the command, store it as a text file, read its contents then removing the temporary text file?
Yes. Basically you need how to learn to redirect the standard output. The following article and code will do exactly what you want and more: Run other programs from your .NET code[^] Hope it helps.[
My articles and software tools