Questions tagged [processstartinfo]

244 questions
205
votes
21 answers

ProcessStartInfo hanging on "WaitForExit"? Why?

I have the following code: info = new System.Diagnostics.ProcessStartInfo("TheProgram.exe", String.Join(" ", args)); info.CreateNoWindow = true; info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; info.RedirectStandardOutput =…
Epaga
  • 35,261
  • 53
  • 143
  • 239
148
votes
12 answers

Executing Batch File in C#

I'm trying to execute a batch file in C#, but I'm not getting any luck doing it. I've found multiple examples on the Internet doing it, but it is not working for me. public void ExecuteCommand(string command) { int ExitCode; ProcessStartInfo…
Wessel T.
  • 2,110
  • 2
  • 19
  • 27
66
votes
3 answers

.NET - WindowStyle = hidden vs. CreateNoWindow = true?

When I start a new process, what difference does it make if I use the WindowStyle = Hidden or the CreateNoWindow = true property of the ProcessStartInfo class?
Gabor
  • 1,548
  • 1
  • 15
  • 25
48
votes
2 answers

Set environment variables for a process

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…
timkado
  • 1,532
  • 2
  • 14
  • 24
30
votes
5 answers

Hanging process when run with .NET Process.Start -- what's wrong?

I wrote a quick and dirty wrapper around svn.exe to retrieve some content and do something with it, but for certain inputs it occasionally and reproducibly hangs and won't finish. For example, one call is to svn list: svn list…
Chris Farmer
  • 23,314
  • 32
  • 110
  • 161
30
votes
1 answer

Run process as administrator from a non-admin application

From an application that is not being run as administrator, I have the following code: ProcessStartInfo proc = new ProcessStartInfo(); proc.WindowStyle = ProcessWindowStyle.Normal; proc.FileName = myExePath; proc.CreateNoWindow =…
jkh
  • 3,380
  • 8
  • 33
  • 58
21
votes
3 answers

Running MSBuild programmatically

I am trying to execute MSBuild programmatically and can't execute the following command: string command = string.Format(@"C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe ""{0}\{1}.csproj""", _args.ProjectPath, _args.ProjectName); The…
foo
  • 1,455
  • 2
  • 11
  • 13
21
votes
3 answers

Elevating privileges doesn't work with UseShellExecute=false

I want to start a child process (indeed the same, console app) with elevated privileges but with hidden window. I do next: var info = new ProcessStartInfo(Assembly.GetEntryAssembly().Location) { UseShellExecute = true, // ! Verb = "runas",…
abatishchev
  • 92,232
  • 78
  • 284
  • 421
17
votes
4 answers

ClickOnce application does not start through Process.Start("x.abc") with *.abc associated to the ClickOnce application

I have successfully developed and deployed a ClickOnce application which registers an associated file extension, for instance *.abc. When I click on a file named x.abc or if I type x.abc from the command prompt, the ClickOnce application starts, and…
Pierre Arnaud
  • 9,402
  • 8
  • 70
  • 102
15
votes
4 answers

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

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…
Chad
  • 2,920
  • 4
  • 27
  • 39
14
votes
6 answers

Win32Exception: The directory name is invalid

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…
mrtaikandi
  • 6,018
  • 14
  • 55
  • 92
12
votes
1 answer

Starting a process synchronously, and "streaming" the output

I'm looking at trying to start a process from F#, wait till it's finished, but also read it's output progressively. Is this the right/best way to do it? (In my case I'm trying to execute git commands, but that is tangential to the question) let…
Benjol
  • 57,639
  • 51
  • 180
  • 252
12
votes
3 answers

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

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, …
GreenRibbon
  • 289
  • 2
  • 16
8
votes
1 answer

Executing a process from .NET application without UAC prompt

I have a scenario where I need to launch an EXE from my .NET application, but I can't get around the UAC prompt that pops up. The prompt is triggered even before the other EXE is launched - probably on the very call to Process.Start. I use this code…
synhershko
  • 4,345
  • 1
  • 27
  • 36
8
votes
1 answer

Execute script using sysinternals PSExec from Asp.Net Web application

I am trying to execute PSExec from my Asp.Net Web application to connect to a remote server. Somehow it gives "Access Denied Error -5" with no credentials set, and by setting the credentials in the PSEXEC command it gives "2250 Network connection…
PSL
  • 120,386
  • 19
  • 245
  • 237
1
2 3
16 17