Perl Script When Launched From the Service Fails to Load Environment Variables

A

ANarula

I am running into a strange problem. I have perl script which reads the
"APPDATA" environment variable, and does some work on that directory.

When I a launch this script from Command Prompt, it works perfectly fine,
however when the same script is launched from a DLL hosted in a particular
Service, the script fails to read the envrionment variable.

Does any one has any clue, whats going wrong ?

Regards,
Abhishek
 
S

Stephen Kellett

Anarula <[email protected]> said:
I am running into a strange problem. I have perl script which reads the
"APPDATA" environment variable, and does some work on that directory.

When I a launch this script from Command Prompt, it works perfectly fine,
however when the same script is launched from a DLL hosted in a particular
Service, the script fails to read the envrionment variable.

Does any one has any clue, whats going wrong ?

The script is most likely loading environment variables, but the
environment variables will be for the account it is running on. Most
likely the service is not running in the same user account as the
account you expect. Try running the service on your user account and see
what happens, or try adding the environment variables to the local or
system account (guess) that your service is running as.

Same comment applies to the registry (I got bitten with this with the
registry - makes sense to me that the environment variables will be the
same).

Stephen
 
B

Bruno van Dooren

I am running into a strange problem. I have perl script which reads the
"APPDATA" environment variable, and does some work on that directory.

When I a launch this script from Command Prompt, it works perfectly fine,
however when the same script is launched from a DLL hosted in a particular
Service, the script fails to read the envrionment variable.

Does any one has any clue, whats going wrong ?

The most probably cause is that the service is running with LOCAL_SYSTEM or
LOCAL_SERVICE account credentials for which that variable is not defined.

To test this you can go to control panel ->administrative services ->
services.
open the properties window for your service, and change the logon
credentials from whatever they are to your own account credentials.

then stop and start the service. if it works then, it means that the
variable does not exist for the LOCAL_SYSTEM or SERVICE account.

--

Kind regards,
Bruno van Dooren
(e-mail address removed)
Remove only "_nos_pam"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top