processstartinfo

Run interactive process inside already-running console application without opening new window

白昼怎懂夜的黑 提交于 2019-11-29 18:27:47
I realize this looks like a lot of other questions out there, but I looked at all of them for hours and never found the real answer I needed, so hear me out: This is for a .NET C# console application. Within it, I wanted to call a Windows executable using Process.Start , but without it opening a new console window when run. I also wanted the executable to be able to output to the console and respond to user input normally. How do you do this? Set ProcessStartInfo.CreateNoWindow , or ProcessStartInfo.WindowStyle ? Try to make input/output redirection work for hours on end? EDIT: smh ... this is

Application started by Process.Start() isn't getting arguments

爱⌒轻易说出口 提交于 2019-11-29 13:55:42
问题 Using C#, I am trying to pass command-line arguments to a new process using Process.Start(): string path = @"C:\Demo\Demo.exe"; string arguments = "one two three"; ProcessStartInfo startInfo = new ProcessStartInfo { FileName = path, Arguments = arguments }; var process = Process.Start(startInfo); My C application Demo.exe just echos the command line arguments: int main( int argc, char *argv[] ) { int count=0; // Display each command-line argument. printf( "\nCommand-line arguments:\n" ); for(

Interact with ffmpeg from a .NET program?

旧街凉风 提交于 2019-11-29 07:13:17
I'm trying to create a .NET wrapper for media-file conversion using ffmepg , here is what I've tried: static void Main(string[] args) { if (File.Exists("sample.mp3")) File.Delete("sample.mp3"); string result; using (Process p = new Process()) { p.StartInfo.FileName = "ffmpeg"; p.StartInfo.Arguments = "-i sample.wma sample.mp3"; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.Start(); //result is assigned with an empty string! result = p.StandardOutput.ReadToEnd(); p.WaitForExit(); } } What actually happens is the content of the ffmpeg program is printed out to

C# - Launch Invisible Process (CreateNoWindow & WindowStyle not working?)

谁说胖子不能爱 提交于 2019-11-29 07:01:09
问题 I have 2 programs (.exe) which I've created in .NET. We'll call them the Master and the Worker. The Master starts 1 or more Workers. The Worker will not be interacted with by the user, but it is a WinForms app that receives commands and runs WinForms components based on the commands it receives from the Master. I want the Worker app to run completely hidden (except showing up in the Task Manager of course). I thought that I could accomplish this with the StartInfo.CreateNoWindow and StartInfo

Win32Exception: The directory name is invalid

↘锁芯ラ 提交于 2019-11-29 01:41:57
I'm trying to run a process as a different user that has Administrator privilege in 2 different computers running Vista and their UAC enabled but in one of them I get a Win32Exception that says "The directory name is invalid" Can anyone tell me what is wrong with my code? var myFile = "D:\\SomeFolder\\MyExecutable.exe"; var workingFolder = "D:\\SomeFolder"; var pInfo = new System.Diagnostics.ProcessStartInfo(); pInfo.FileName = myFile; pInfo.WorkingDirectory = workingFolder; pInfo.Arguments = myArgs; pInfo.LoadUserProfile = true; pInfo.UseShellExecute = false; pInfo.UserName = {UserAccount};

Run interactive process inside already-running console application without opening new window

泄露秘密 提交于 2019-11-28 14:16:37
问题 I realize this looks like a lot of other questions out there, but I looked at all of them for hours and never found the real answer I needed, so hear me out: This is for a .NET C# console application. Within it, I wanted to call a Windows executable using Process.Start , but without it opening a new console window when run. I also wanted the executable to be able to output to the console and respond to user input normally. How do you do this? Set ProcessStartInfo.CreateNoWindow , or

Process.Start Permissions Problem

不羁岁月 提交于 2019-11-28 13:35:30
I'm trying to run an external problem from C# by using Process.Start, but am running into permissions issues. When I open a command prompt normally (not as an admin) and run my commands they work fine, but when I open a command prompt via Process.Start, I get a write error on the directory. ("I can't write on file test.log") If I run it as an admin via Process.Start it works fine, but I get the permissions popup. Does anyone have any ideas that might help me figure this out? Thanks! Here is the code I'm using: Process proc = new Process(); proc.StartInfo.FileName = @"cmd.exe"; proc.StartInfo

Sending input/getting output from a console application (C#/WinForms)

给你一囗甜甜゛ 提交于 2019-11-27 22:37:38
I have a form with 3 controls: A textbox for the user to enter commands to send to a console application, A button to confirm the commands to be sent and A read-only textbox to display the output from the application. What I want is for the user to enter commands in the first textbox, press the button to enter and receive feedback via the second textbox. I know how to use ProcessStartInfo.RedirectStandardOutput but, however, the app hangs when I use StandardOutput.ReadToEnd() . I had a look at the asynchronous Process.BeginOutputReadLine() but, even though my app does not hang, somehow I get

Win32Exception: The directory name is invalid

你说的曾经没有我的故事 提交于 2019-11-27 16:07:47
问题 I'm trying to run a process as a different user that has Administrator privilege in 2 different computers running Vista and their UAC enabled but in one of them I get a Win32Exception that says "The directory name is invalid" Can anyone tell me what is wrong with my code? var myFile = "D:\\SomeFolder\\MyExecutable.exe"; var workingFolder = "D:\\SomeFolder"; var pInfo = new System.Diagnostics.ProcessStartInfo(); pInfo.FileName = myFile; pInfo.WorkingDirectory = workingFolder; pInfo.Arguments =

Set environment variables for a process

时光怂恿深爱的人放手 提交于 2019-11-27 07:24:06
What is the environment variable concept? In a C# program I need to call an executable. The executable will call some other executables that reside in the same folder. The executables rely on the two environment variables "PATH" and "RAYPATH" to be set correctly. I tried the following two things: I created a process and set the two varables in StartInfo. The variables exist already but are missing the needed information. I tried to set the variables with System.Environment.SetEnvironmentVariable(). When I run the process the system can't find the executable ("executeable1"). I tried to set