With the help of various wise monks, I have been able to solve most of my problems. I am now stuck with one bit that is posing to be particularly vexing --
In order to provide user-control, my program uses an external config file that is read in during the Win32 service startup loop. So, a user can stop the service, change config params, and restart the service. It works.
But, here is the problem -- the config file itself has to be specified in the program with its path hardcoded. As I understand, the Win32 service control manager (SCM) doesn't understand relative paths as the service runs as a local system account. So, before I can convert my perl script to an exe via pp, the script has to have the config file long path encoded in it. Of course, when I transfer the exe to another computer, the path may not be the same as mine (for example, my computer, doesn't have a C: drive -- for some reason, it is now E: drive). So, I have a bit of code like so
It is these hardcoded instances of pathnames that I want to avoid. Or, at least make them configurable on the target machine. In other words, I want to above paths to be malleable when I convert foo.pl -> foo.exe.BEGIN { open(STDERR, ">>E:/foo/bar.err") or die "invisible error"; warn "$0 started ".localtime().$/; } .. # and then, further down .. Config::Simple->import_from('E:/foo/foo.conf', \%c);
Then I want to copy foo.exe and foo.conf to the target user under, say, P:\programs\foo\ (or some arbitrary directory), and change $path to P:/programs/foo/ within foo.exe before converting foo.exe -> Win32 service.BEGIN { open(STDERR, ">>$path/bar.err") or die "invisible error"; warn "$0 started ".localtime().$/; } .. # and then, further down .. Config::Simple->import_from('$path/foo.conf', \%c);
How to do that?
In reply to how to make pp-created exe read external config values by punkish
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |