ProcessStartInfo
-
Hi, I have a C# program that will start another external program (such as notepad). The C# program needs to pass arguments and the working directory to the external program. I have attempted to do this like: Process process = new Process(); try { process.StartInfo.UseShellExecute = false; process.StartInfo.FileName = @"c:\Windows\notepad.exe"; process.StartInfo.Arguments = @"c:\test.txt"; process.StartInfo.WorkingDirectory = @"c:\temp"; process.Start(); process.WaitForExit(); } catch { MessageBox.Show("Error running " + strExe, "Error", MessageBoxButtons.OK); } Notepad does start and opens the correct file, but the Working Directory has not been set. I have tried setting the current directory of the C# applicaiton, then running the notepad process, but the Working Directory is still not set. Please help! Pete
-
Hi, I have a C# program that will start another external program (such as notepad). The C# program needs to pass arguments and the working directory to the external program. I have attempted to do this like: Process process = new Process(); try { process.StartInfo.UseShellExecute = false; process.StartInfo.FileName = @"c:\Windows\notepad.exe"; process.StartInfo.Arguments = @"c:\test.txt"; process.StartInfo.WorkingDirectory = @"c:\temp"; process.Start(); process.WaitForExit(); } catch { MessageBox.Show("Error running " + strExe, "Error", MessageBoxButtons.OK); } Notepad does start and opens the correct file, but the Working Directory has not been set. I have tried setting the current directory of the C# applicaiton, then running the notepad process, but the Working Directory is still not set. Please help! Pete
How do you know this isn't working? How do you know what Notepad is receiving for its working directory? Its file open/save dialogs remember the last directory you used.
Help me! I'm turning into a grapefruit! Buzzwords!
-
Hi, I have a C# program that will start another external program (such as notepad). The C# program needs to pass arguments and the working directory to the external program. I have attempted to do this like: Process process = new Process(); try { process.StartInfo.UseShellExecute = false; process.StartInfo.FileName = @"c:\Windows\notepad.exe"; process.StartInfo.Arguments = @"c:\test.txt"; process.StartInfo.WorkingDirectory = @"c:\temp"; process.Start(); process.WaitForExit(); } catch { MessageBox.Show("Error running " + strExe, "Error", MessageBoxButtons.OK); } Notepad does start and opens the correct file, but the Working Directory has not been set. I have tried setting the current directory of the C# applicaiton, then running the notepad process, but the Working Directory is still not set. Please help! Pete
How did you know that the WorkingDirectory was not set?
It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.
-
How do you know this isn't working? How do you know what Notepad is receiving for its working directory? Its file open/save dialogs remember the last directory you used.
Help me! I'm turning into a grapefruit! Buzzwords!
I've found out that it does work after all. I started a batch file that printed the current directory and ran this from the process and it did print the Working Directory!!! I've spent ages trying to get it working with Notepad and kept trying the File/Save As... to see if the folder was the Working Directory. I didn't realise that it was always the last one used. Pete
-
How did you know that the WorkingDirectory was not set?
It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.
I've found out that it does work after all. I started a batch file that printed the current directory and ran this from the process and it did print the Working Directory!!! I've spent ages trying to get it working with Notepad and kept trying the File/Save As... to see if the folder was the Working Directory. I didn't realise that it was always the last one used. Pete