Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.
  • I have a sheduling engine that runs jobs on windows 2003 server.
  • It runs as a particular domain user DOM\mtidsql.
  • I don't have access to log on as the user but I have admin access.
  • I need to be able to script storing a password in an environment variable that is specific to the user
  • The user does not appear to have an environment on the target platform because HKU\SID does not exist in the registry for the user. (SID is the users domain SID) but it has a profile C:\Documents And Settings\mtidsql
  • HKU\SID does not exist
  • I cant add HKU\SID\Environment\VAR_NAME .... using reg.exe, it returns ERROR: The parameter is incorrect.
share|improve this question

2 Answers 2

Here's a few ideas:

  • You could mount the user's registry hive and add the value manually. Look at the "Load Hive..." functionality in REGEDIT.

  • You could logon interactively as the user and add the appropriate value using the GUI.

  • You could use "RUNAS" to open a command-prompt as the user and add the value to their registry (HKEY_CURRENT_USER\Environment) from there.

share|improve this answer
    
Thanks: GUI is not an option, this is a scripted install + I don't know the user password –  Paddy Carroll May 11 '11 at 14:19
    
@Paddy Carroll: When you say "a scripted install" it makes me wonder if you can just shoehorn a "REG ADD HKEY_CURRENT_USER\..." into the installation script. If not, look at using "REG LOAD" and "REG UNLOAD" to load the user's hive, add the entry to it, and unload the hive. –  Evan Anderson May 11 '11 at 14:41
    
REG ADD has been tried and failed ( as described ), reg load\save only operate on the local machine –  Paddy Carroll May 12 '11 at 9:52
    
@Paddy Carroll: Your posting doesn't mention the use of "REG ADD". It does indicate that you're trying to add to "HKU\SID\...". That's going to be problematic. Running "REG ADD HKCU\..." or loading the user's hive and modifying it will work. Adding to "HKU\SID\..." will not. Insofar as "REG LOAD" running on the local machine just run the script on the machine where the profile is located. Why can't you do that? You can also "REG LOAD" a hive from a UNC path just fine, too, so you could mount the hive on your machine remotely, modify it, and unmount it. –  Evan Anderson May 12 '11 at 12:02

You can probably use Group Policy Preferences to set the environment variable, but I've not really tested it for a user like you describe. And like any GPO, you can put security filtering on it to ensure that only the one user can apply it. Example given below:

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.