I have a local service (written in C#), running on Windows 7, 64-bit, that monitors a folder (via a file system watcher) and when the appropriate file type (.xml, in this case) appears it calls a reader application with the full path of the document file as a parameter. Currently the reader app is Notepad. Everything seems to work fine; when the file is dropped into the folder I can see in Task Manager that Notepad is running, but I can’t see it! It’s running in the background with no UI. I’ve tried other file reader apps, so it’s not that, it must be something to do with the way it’s being called. This is the current code, but I’ve tried other variations, particularly with the ProcessStartInfo.
var workingDirectory = Path.GetDirectoryName(this.readingApplication) ?? Path.GetTempPath();
this.eventLog1.WriteEntry(
"In OpenTheMessage. Working Directory: " + workingDirectory,
EventLogEntryType.Information,
++this.eventId);
var info = new ProcessStartInfo
{
FileName = this.readingApplication,
Arguments = xmlFileMessage,
WindowStyle = ProcessWindowStyle.Normal,
UseShellExecute = true,
WorkingDirectory = workingDirectory
};
this.eventLog1.WriteEntry(
"In OpenTheMessage. Run: " + this.readingApplication + " " + xmlFileMessage,
EventLogEntryType.Information,
++this.eventId);
Process.Start(info);
I can see from the event log that the program flow is correct. I can even copy the command from the log into Windows Run and it works. What is going on here?