Login script to edit user.dat file for Roaming Profile users

I need to edit the ntuser.dat file when a user logs in to my citrix/terminal server.  Basically whats happening is the pointer for a new app we are running has the database location stored in the NTUSER.dat file.  

I am using roaming profiles and have a bunch of users that have already logged in and got the settings for the first database location.  

We have since added 2 more and when the user logs in they still only see 1 database.  This is because they way the app is written it checks the ntuser.dat file in the user profile first.  

If there is a pointer in there it just uses whats there.  If there is no pointer in ntuser.dat/profile then it looks at the HKEY_LOCAL_MACHINE - software -section and pulls the info from there and then writes to the user profile.  

I tried to go into regedit and load a hive from a user where the settings are located then tried to copy into the All Users hive but it didnt work.  IM guessing becuase it is a roaming profile.  

Any suggestions?  I was thinking a login script would be the way to go but im not sure...Thanks for any help!  
GPEAL383Asked:
Who is Participating?
 
connectexCommented:
regedit /s filename.reg should do the import without the prompt. As long as the changes are under HKCU it should work for any non-admin user.
0
 
connectexCommented:
This may seem like I'm out of left field but just follow my thinking and hopefully you'll get this done quickly and easy. Check out this article: http://support.microsoft.com/kb/252330. To review, it says when using install mode any changes to the HKCU hive are replicated to another registry location (install key). This way the same changes can be made for each user's version of HKCU hive in their ntuser.dat file. Of course this is especially important for a new user profile. So you should be able to do "change user /install" and make the registry changes in HKCU hive. Then switch back to execute mode "change user /execute". Note the article it wrong it's not iexecute. They copied the previous line but didn't modify it correctly. Now logon as another user account and confirm the registry changes took for this user. If they didn't then there's one more thing we need to do. I know I've read it somewhere, in contrast the the fore reference Microsoft article, that the terminal services code will handle HKCU request differently. It will check for the entry in HKCU. If it doesn't exists, will check the install key section and add it, if needed. So you may need to create a .reg file to remove the problem keys/values from the HKCU hive first. To do so you can just add a icon to the all user's start group for this. Here's an article covering how to use regedit and .reg files to add or remove keys/values: http://support.microsoft.com/kb/310516/EN-US
0
 
GPEAL383Author Commented:
The "change user /install"  I thought that was for a 2000 server?
0
Network Scalability - Handle Complex Environments

Monitor your entire network from a single platform. Free 30 Day Trial Now!

 
connectexCommented:
The "change" command has existed since Citrix WinFrame days. That's before Microsoft took over Citrix's MultiWin technologies which later become Windows NT 4.0 Terminal Services Edition. Still even works on Windows 2008 R2! Also did you know Citrix originally started on OS2!
0
 
GPEAL383Author Commented:
Ignore my last post...I was not thinking...I put the server in install mode and im going to see what happens.....
0
 
GPEAL383Author Commented:
I tried the install mode and it didnt work.  I see where your going with deleting the reg key.  I think this might work.  When the user.dat file is loaded into the reg does it load the settings into HKCU?  Im trying to figure out how windows handles this when a user logs in.  I know it doesnt load HKEY_USER - NTUSER file so it must look at the settings in the ntuser.dat file and load them somewhere?  Does this make sense?
0
 
connectexCommented:
All the various registry hives come from files stored on the system. Most of the files are stored in %systemroot%\system32\config. But the HKCU is always loaded from the ntuser.dat file in the logged user's profile folder. This way each user can have their own personal settings. This article provides more information: http://msdn.microsoft.com/en-us/library/ms724877(v=vs.85).aspx 

Also another way to review, export, and make changes to an unmounted registry hive by using regedit's load hive option. To do so open regedit. Click on the HKLM hive. Choose load hive on the file menu. Now choose a browse and choose a registry hive file. Now provide a name for the key to load it under. The hive will be under HKLM\<name you just typed>. Now you can do as needed to the hive. Just remember to unload the hive when done via the file menu. And also if you export to any .reg files they will need to be fixed via replacing HKLM\<loaded hive key> to what ever hive location they really should be imported in the future.
0
 
GPEAL383Author Commented:
I think I might have a way to fix it but I have only tested as administrator.  

If i run a reg file on startup it looks like it fixes the issuse.  I have 2 problems though.

1. I added the reg key to startup and it prompts the user "Do you want to add this to reg?" you then have to hit yes and then when it adds it you have to click ok.  I want this to be seamless to the user and I want to run as login script NOT in the startup folder.

2.  This is working under admin only.  My citrix users are locked down and have redirected desktops/start menus's.  I dont think I reg user has acces to add a reg key.

Is there a script i can run that adds a reg key automatically whithout the user having to click anything and not being an admin?

Thanks
0
 
GPEAL383Author Commented:
How would I use this as a script...would i create a batch file?
0
 
GPEAL383Author Commented:
Should I just create a cmd file and put the .reg file in the scripts folder and then just user GP to push out?  I think thats what you were getting out...im going to test now.  
0
 
connectexCommented:
You should be able to just add an shortcut or icon to C:\Documents and Settings\All Users\Start Menu\Programs\Startup. That will run it for all users that logon to the system.
0
 
GPEAL383Author Commented:
Thanks got it working with the reg key script like you said with the /s.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.