Solved

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

Posted on 2011-02-24
12
676 Views
Last Modified: 2012-05-11
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!  
0
Comment
Question by:GPEAL383
  • 7
  • 5
12 Comments
 
LVL 13

Expert Comment

by:connectex
ID: 34977302
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
 

Author Comment

by:GPEAL383
ID: 34980267
The "change user /install"  I thought that was for a 2000 server?
0
 
LVL 13

Expert Comment

by:connectex
ID: 34980305
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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

Author Comment

by:GPEAL383
ID: 34980307
Ignore my last post...I was not thinking...I put the server in install mode and im going to see what happens.....
0
 

Author Comment

by:GPEAL383
ID: 34980625
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
 
LVL 13

Expert Comment

by:connectex
ID: 34980995
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
 

Author Comment

by:GPEAL383
ID: 34981066
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
 
LVL 13

Accepted Solution

by:
connectex earned 500 total points
ID: 34981133
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
 

Author Comment

by:GPEAL383
ID: 34981154
How would I use this as a script...would i create a batch file?
0
 

Author Comment

by:GPEAL383
ID: 34981335
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
 
LVL 13

Expert Comment

by:connectex
ID: 34981928
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
 

Author Closing Comment

by:GPEAL383
ID: 34982226
Thanks got it working with the reg key script like you said with the /s.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Citrix policies are the most efficient method to configure and tune XenDesktop environments, allowing organizations to control connection, security and bandwidth settings based on various combinations of users, devices or connection types.  Citrix …
Most of the applications these days are on Cloud. Cloud is ubiquitous with many service providers in the market. Since it has many benefits such as cost reduction, software updates, remote access, disaster recovery and much more.
How to install and configure Citrix XenApp 6.5 - Part 1. In this video tutorial we have explained step by step installation of Citrix XenApp 6.5 Server on Windows Server 2008 R2 is explained in this video. We have explained the difference between…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question