1

I've run into an issue with one of my systems where multiple Oracle versions are installed for the support of various applications, but I need to run a program as a Windows service using the Local System account. Currently, I am getting the following error:

System.Exception: OCIEnvNlsCreate failed with return code -1 but error message text was not available.

but I have been informed that this is likely due to the environment variables for the Local System account being set incorrect. As such, how do I go about actually changing the values for the Local System account?

anonymous
  • 267
  • 8
  • 17

2 Answers2

3

If you don't mind it being set system-wide, just set it in the System section of the "Environment Variables" dialog in the from the "Advanced" page of the "My Computer" properties. That will definitely set it for the SYSTEM context. You could always over-ride it on a per-user basis, too.

If you really want to set it on the SYSTEM context only, add it to: HKEY_USERS\.Default\Environment

If you want to use the Explorer UI to do that, start a command-prompt as SYSTEM using the "at (time now + 1 minute) /INTERACTIVE CMD" trick from the console session, kill the Explorer process running as your user account, and start Explorer from the SYSTEM command prompt. (This is getting into really "unsupported" territory, and I don't necessarily encourage that you do it...)

I'd just set the system-wide environment variable.

Evan Anderson
  • 141,881
  • 20
  • 196
  • 331
  • Your answer is two parts. The first part, "System section of Environment Variables dialog" does not work on Server 2008 R2. – daveloyall Jul 08 '15 at 23:32
  • @daveloyall - I'm not following you. The System section of the "Environment Variables" dialog, accessible from the "Advanced" tab of the computer's "Properties" sheet is definitely present in Windows Server 2008 R2 (and later versions of Windows Server). An environment variable specified there will be available in the default environment of all newly-created processes after the entry is added (unless overridden by a user-level environment variable). I don't see any behavior differences in W2K8R2 as compared with earlier or later versions of Windows Server. Perhaps you can elaborate. – Evan Anderson Jul 09 '15 at 03:09
  • Yes, what you described is what I expected based on what I read on the internet. Including the bit about "all newly-created processes [will receive the new environment]". However, it did not work for me. Later, I learned that my processes DID get the new environment after a reboot... – daveloyall Jul 09 '15 at 14:11
1

I would alternatively look at creating a dedicated service account, grant it the rights it needs, configure the service to run under those credentials, and set the ORACLE_HOME variable for that account's profile. You'll find it's easier to audit what your program is doing that way too.

Maximus Minimus
  • 8,987
  • 2
  • 23
  • 36