?
Solved

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

Posted on 2011-02-24
12
Medium Priority
?
703 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

 

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 2000 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

Manage your data center from practically anywhere

The KN8164V features HD resolution of 1920 x 1200, FIPS 140-2 with level 1 security standards and virtual media transmissions at twice the speed. Built for reliability, the KN series provides local console and remote over IP access, ensuring 24/7 availability to all servers.

Question has a verified solution.

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

During and after that shift to cloud, one area that still poses a struggle for many organizations is what to do with their department file shares.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses

765 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