views:

66

answers:

5

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. Below is the code used to launch the process which runs the file. Any ideas?

    protected override void OnStart(string[] args)
 {
  // 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
        process1.Start();
 }
A: 

My first instinct is to check permissions.

Russell Newquist
Yea that was one of the first things I was thinking too. I checked all the permissions, and they are all correct.
Ben
A: 

Is the file extension registered on the server? It could be that the server is failing to find an action associated with .avc. You might want to move this to ServerFault since it is most likely a configuration or Windows OS version difference.

D.Shawley
A: 

You may want to put a try catch block in that method and write out any exception to the event log, this should piont you in the write direction.

But as D.Shawley said it sounds like a config issue.

Robert
Yea I think this is a config issue. I put a try catch block in the method, and unfortunately there are no exceptions being thrown.
Ben
A: 

This problem definitely has to do with the .avc not being associated correctly to the program itself, because I can run the program itself through the service just fine. I think what I need to do is open the actual program up itself then pass the file into it to open, like opening paint and passing a picture to it to open. I just need to find the syntax to do that.

Ben
A: 

Ok, once again 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";
Ben