Solved

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

Posted on 2011-02-24
12
668 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
Comment Utility
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
Comment Utility
The "change user /install"  I thought that was for a 2000 server?
0
 
LVL 13

Expert Comment

by:connectex
Comment Utility
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
 

Author Comment

by:GPEAL383
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:GPEAL383
Comment Utility
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
Comment Utility
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
Comment Utility
How would I use this as a script...would i create a batch file?
0
 

Author Comment

by:GPEAL383
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks got it working with the reg key script like you said with the /s.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

If your business is like most, chances are you still need to maintain a fax infrastructure for your staff. It’s hard to believe that a communication technology that was thriving in the mid-80s could still be an essential part of your team’s modern I…
PRTG Network Monitor lets you monitor your bandwidth usage, so you know who is using up your bandwidth, and what they're using it for.
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now