Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I created a simple Windows service in dot net which runs a file. When I run the service locally I see the file running in the task manager just fine. However, when I run the service on the server it won't run the file. I've checked the path to the file which is fine. I also checked the permissions on the folder and file, and they fine as well. Also there are no exceptions happening. Below is the code used to launch the process which runs the file. I posted this first on stack overflow, and some people were thinking this is a config issue, so I moved it here. Any ideas?


            // TODO: Add code here to start your service.
            eventLog1.WriteEntry("VirtualCameraService started");

            // Create An instance of the Process class responsible for starting the newly process.

            System.Diagnostics.Process process1 = new System.Diagnostics.Process();

            // Set the directory where the file resides
            process1.StartInfo.WorkingDirectory = "C:\\VirtualCameraServiceSetup\\";

            // Set the filename name of the file to be opened
            process1.StartInfo.FileName = "VirtualCameraServiceProject.avc";

            // Start the process
        catch (Exception ex)
            eventLog1.WriteEntry("VirtualCameraService exception - " + ex.InnerException);
share|improve this question
What happens when you try to start VirtualCameraServiceProject.avc interactively on the server? – squillman Nov 9 '09 at 17:39
If I try and start VirtualCameraServiceProject.avc either from the command line or from windows explorer it opens the program associated with it, which is what I should see running in task manager. – Ben Nov 9 '09 at 17:41
When you say you run the service locally do you mean you run it "As a Service" and it works or do you mean you run it as a user interactively on your developer system or as a proper" Windows Service"? What OS does it run successfully under, and what is the OS that it fails on? Is it always installed on a local disk on the systems you are trying to execute it on? – Helvick Nov 9 '09 at 20:31

Ok, so the problem was that the file wasn't associated to the program on the server. So instead of trying to open the file I needed to open the program to run the file, then pass the file as an argument to the program. Below is the syntax.

 // Set the directory where the file resides
            process1.StartInfo.WorkingDirectory = "C:\\Program Files (x86)\\Axis Communications\\AXIS Virtual Camera 3\\";

            // Set the filename name of the file to be opened
            //process1.StartInfo.FileName = "VirtualCamera.exe C:\\VirtualCameraServiceSetup\\VirtualCameraServiceProject.avc";
            process1.StartInfo.FileName = "VirtualCamera.exe";
            process1.StartInfo.Arguments = "VirtualCameraServiceProject.avc";
share|improve this answer

Try replacing "C:\Path to File.avc" with "C:\Path to Program that opens AVC files\ProgramName.exe" "C:\Path to File.AVC" and see if that changes anything. I've seen this happen before where someone opening a file of a certain type by double-clicking on the file works OK interactively (on account of file association) but when called as a batch job, a service, or similar, it needs the actual exe name with the file name passed as a param.

Also double-check that your service is allowed to interact with the desktop as that might be required (although depending on your version of Windows server this option may not be there, as it's been removed in newer versions).

share|improve this answer
The problem definitely has to do with the .avc not being associated correctly to the program itself, because I can run the program through itself through the service just fine. I tried the syntax of "C:\Path to Program that opens AVC files\ProgramName.exe" "C:\Path to File.AVC" which didn't work for me unfortunately. But I know that I'm on the right path now. I just need to get the syntax right for opening a program and passing a file to it to open. – Ben Nov 9 '09 at 19:15
process1.StartInfo.Arguments should do it. – 21st Century Moose Nov 9 '09 at 19:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.