PDA

View Full Version : FG2 exe question



Bidmaron
January 15th, 2011, 23:52
I was trying to make my background program startup FG2 if it isn't running, but when I use Process.Start, I get the following error:
"Could no load ruleset root file base.xml
Do you want to try reloading the data?"

There must be a command-line parameter that's required, but does anyone know what I'm missing?

drahkar
January 16th, 2011, 00:03
Sounds like it might be starting it, but not setting the proper working directory. If thats the error you are getting before it even shows the launcher interface for creating campaigns and such then it means whatever is starting it has done so it such a way that it can't find launcher.pak in the FG2 program directory.

Zeus
January 16th, 2011, 00:35
Yes sounds to me like its unable to locate the base.xml in the launcher.pak in the Fantasy Grounds program directory.

Which overload for System.Diagnostics.Process.Start() are you using? Have you tried using the ProcessStartInfo overload and setting the environment and path variables for the process or forcing it to read a User Profile from the registry before executing?

Bidmaron
January 16th, 2011, 03:22
Zeuss, I am a Mac guy, so Windows programming is sometimes challenging for me. I am using Visual Studio 2008 c# (also have sqlserver express installed). I hate to be a burden, but which environment and path variables should I set? I guess I was naive to think process.start was the same thing as if you double-clicked the exe file.

Also, I currently have the fg2 exe path hard-coded, which won't work if user has it installed somewhere other than normal. I was trying to use the oft-cited technique to go through the windows uninstall registry list to find the path for fg2, but when I enumerate the list (using code like here (https://www.codeproject.com/KB/files/CoolCode.aspx)) most of my software isn't on there. When I go to control panel to whatever they're calling Add/Remove Programs these days (why does Microsuck always change their control panel setup every time they increment the system number?), Fg2 is certainly there for uninstallation.

I wanted to try another technique I found elsewhere that required sql on the wpi classes, but even though the visual studio help insists that SelectQuery class is in System.Management, there is no such class there. In fact there is almost nothing in that namespace.

None of this is really critical, as I can just make the user startup FG2, but it's always nice to make things as easy as possible. I just wish microsuck would do that.

StuartW
January 16th, 2011, 07:21
Although not really answering the main question, the install path and data path for FG can be found from the following registry entries:


HKEY_CURRENT_USER\Software\Fantasy Grounds\2.0\InstallDir
HKEY_CURRENT_USER\Software\Fantasy Grounds\2.0\DataDir
That might be easier than looking through the uninstall list.

Stuart

Bidmaron
January 16th, 2011, 13:29
Why thank you very much, Stuart. While I'll remain intellectually curious as to why the uninstall list doesn't work, I'll also not care (at least if and until I ever have some other reason to want it to work, but that is microsoft for you -- if you want to know what programs are installed, please be sure to check the UNINSTALL list -- of course, why didn't I think of that?). I still have to research what kind of environment I need to set up so fg2 runs properly....

Zeus
January 16th, 2011, 13:36
I'd hazard a guess that it might help if both of the paths defined in the registry keys pointed out by StuartW are defined within a ProcessStartInfo object that you instantiate for the fantasygrounds.exe process.

Then use System.Diagnostics.Process.Start(myProcessStartInf o) with your ProcessStartinfo object (myProcessStartInfo) to start FGII.

Bidmaron
January 16th, 2011, 22:54
The only field in ProcessStartInfo that I can see that fg2 might possibly care about is the working directory, which I'm going to try setting to the data directory as you suggest, Zeuss.

Bidmaron
January 17th, 2011, 16:13
I successfully started up fg2 programmatically. The only problem with the technique I'm using is that if someone has to use command lines to start fg2 (e.g. a different port or the -r flag), my technique just starts up with no command line right now. Maybe later, I'll add a preference to put in the command line parameters you want for startup.


string fgDir=GetfgProgramDirectory(); //this function goes out and examines the fantasy grounds registry keys for the InstallDir value and returns it
ProcessStartInfo fgProcessStart=new ProcessStartInfo(Path.Combine(fgDir,"FantasyGrounds.exe"));
fgProcessStart.WorkingDirectory=fgDir;
Process fgProcess=Process.Start(fgProcessStart);

That seems to work fine. After this, my program goes into a timeout loop to scan the data directories and wait for the user to get fg2 running in either client, host, or local mode, which I can determine by looking to see which files are modified/created.

Zeus
January 17th, 2011, 16:47
Excellent stuff, looking forward to seeing this tool in action.