I have a requirement to check for and start a process if it is not already running on our remote server. The problem I am having is the process starts as a background process, which is not desired. Here is the code I am using to start the process:
public Process StartUploader()
{
try
{
var uploaderLocation = Properties.Settings.Default.CaptureLifeUploaderLocation;
var uploadProcess = uploaderLocation + Properties.Settings.Default.CaptureLifeUploaderFilename;
Logger.Info($"Checking {uploaderLocation} for {Properties.Settings.Default.CaptureLifeUploaderFilename}");
if (Directory.Exists(uploaderLocation))
{
var files = Directory.EnumerateFiles(uploaderLocation).Count();
if (files > 0)
{
return Process.Start(uploadProcess);
}
}
var errorMessage = $"{uploadProcess} not found. Please check the directory/filename and try again.";
Logger.Error(errorMessage);
throw new FileNotFoundException(errorMessage);
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex);
}
}
When I run this locally, the process in question starts in the foreground as expected. When it is ran on the server, not so much. The AppPool is set to the same Identity as the 'user' on the server that the program is installed under. I have tested this with notepad.exe and have the same issue with that program.