1

Currently I have a plugin for Petrel that is used in batch mode. So Petrel is launched from the command line, with the class/method to run specified via command line parameters. All fairly straight forward.

However, I'd like this operation to be performed from a Windows service. Simple experimentation suggests this won't work due to Petrel needing to open a window and thus needing to be run from a logged in user account.

Is there a way around this, or is it impossible to run Petrel from a service?

RJFalconer
  • 10,890
  • 5
  • 51
  • 66
David Arno
  • 42,717
  • 16
  • 86
  • 131

1 Answers1

2

You may be able to use PetrelEngine. It is normally used to launch Petrel in silent mode for automated testing, but I think it might work for you.

PetrelEngine.Instance.Initialize("-licensePackage Package1");
  • I had thought that PetrelEngine was for unit testing only. This is definitely worth exploring further. However, looking at the API docs, it looks like the Initialize(args) method returns void and only throws an exception if its already initialised or if called from Petrel in non-exec mode. Does it report eg an unavailable license error in any way? – David Arno Jul 18 '14 at 13:29
  • PetrelEngine simply starts Petrel so that you can start using the various services. From there you can call `PetrelSystem.ProjectService.OpenPrimaryProject("path/to/project")`. Or you can launch a new/empty project by calling `PetrelSystem.ProjectService.NewPrimaryProject()`. As for the licensing, I believe it should work just as if you were launching Petrel normally. That is that I think you will get an exception if no license can be found. When launching Petrel normally you would just get an error popup. – Nathan Phetteplace Jul 18 '14 at 14:32