Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Importing Registry hive using Login Scripts 1

Status
Not open for further replies.

tyarber

IS-IT--Management
Oct 5, 2006
41
0
0
US
I have been working the last 2 days to find out the proper syntax to enter into our login scripts for users.

We currently have a handful of very basic .bat files that load shared drives at login for different users (admin.bat , common.bat , cad.bat ect, ect...).

What i'm doing is trying to insert a command where a registry hive is imported into the HK_CURRENT_USER hive during user login.

I have tried three different commands:

Tried this first, but gave me error that it couldnt load the .reg file. I figured it was because of permissions.

regedit /S \\ppipdc01\d$\last500.reg

Then I tried this;

run as /user:adminsitrator@ppipdc01 /password "*******" "regedit /S \\ppipdc01\d$\last500.reg"


And finally this; My therory on this one is that if I actually put the .reg file where users had access/permission
to it, then it would load it.
run as /user:adminsitrator@ppipdc01 /password "*******" "regedit /S \\ppipdc01\Shared Resources\shared file storage\last500.reg

I tested all these on a test Laptop, logging in and out with user logins and I noticed that the script ran fine all the way up to after the password was used and it still didnt load the .reg file into the registry where I need it. Now I can go from station to station and put this reg hive where I need it. I tring to learn here and want to do it through a login script... Maybe I have to do something in the GPO?? Dont know


I think I'm close so any help is much appreciated.
 
I just noticed I miss spelled administrator :)


re-testing
 
Have you just tried to test this on a single computer from the command line instead of trying it from a login script? My general practice with login scripts is that I run through each line manually from a test workstation to see if any of my lines crap out.

Also, is this .reg file an export from another registry? When you manually load it, are you just double-clicking on the .reg file and saying "Yes"?
 
Oh, I noticed you had misspelled administrator as well, but figured it was just a typo in your post.
 
I am actually putting this in the .bat file to run at login. I just use my laptop to login as a common user and see if it works.

FYI, I also added the first line in our admin.bat login and when I login as administrator on that laptop it works great.

So what i'm doing is adding - regedit /S \\ppipdc01\d$\last500.reg to the admin.bat and login the laptop under administrator and it adds the registry hive as needed.

Doing the said above but putting that same syntax in the common.bat and try to login as a normal user, it won't pull the .reg file and import it into the registry.
 
Yes, when it is manually loaded its a double click and then click yes to execute.

And yes it was exported out onto a desktop(Server) for me use it.
 
The reason I said to type that line at the command line is you will receive more feedback that you would get from a login script (unless you put pauses in). If that runas is at the end of your login script, and it errored at the end, you would probably not even see it.

It is entirely possible that the runas command does not like your spaces. I've seen places where you need double quotes in the runas line if you have spaces in the path to the .reg file, so:

runas /user:administrator@ppipdc01 /password "*******" "regedit /S "\\ppipdc01\Shared Resources\shared file storage\last500.reg
 
Ok, I did what you suggested and finally got it to work. But with out /password "password" on the syntax... Without that password being in there its going to defeat the purpose of what I need to do. I want this to happen without any user intevention or me having to go to the workstation and entering the password when prompted.

Because it does take administrative privilages, there will need to be a password provided. Maybe I need to run a VB type script against the user login so this can happen. And I don't know much about that :)

Thanks alot for helping chipk, I guess I need further instruction/help though. I'm willing to bet you can help me through this though.
 
Which hive are you importing to?

You're correct that you can accomplish this with vbscript (the reg.write function), and another tool, called reg.exe from the Windows 2000 Support Tools.
 
Umm i've always used

regedit /s "filename.reg"

in a batch file.. during login (all our users are admins) it just pulls it into the registry without prompt. The reg file stores all the entries that are to be imported.
 
Yes, Auger, tyarber has been trying to do that, unsuccessfully. Users cannot make changes to all registry hives/keys, which is why I asked which hive tyarber is importing to. The benefit of using reg.exe is you can modify remote registries without placing an administrator password in a login script to modify those parts of the registry that are typically restricted (because you just run it logged in as admin).
 
You could also use this if you need to place a password in the script, it will encrypt the script and run it with eivated privilages.



If you are managing alot of clients then you could also use the Group Policy registry extension which i find invaluable (this is a true client side extension to Group Policy so no client services are required). MS have just purchaced the company so i'm not sure how long it will be free for.

 
chipk, the hive goes under HK_CURRENT_USER. Which if I believe makes this more difficult on me since the current user needs to be login in for me to accoplish what I need.
 
Right you are. I think Porkchopexpress's suggestion is a good one. Of course, that key may exist elsewhere (and therefore be able to be imported somewhere else), like HKEY_USERS, or HKEY_LOCAL_MACHINE.

However, if you're importing to HKEY_CURRENT_USER, you should have NO permission problems from the login script aspect. By default, I believe the "current user" has full control of that hive, so I don't think permissions are your problem.

HKEY_CURRENT_USER loads it's information from HKEY_USER\.default, I believe, so you may want to explore making the change there if it is the same for everyone.

p.s. what is it exactly that you're trying to accomplish here with importing these registry settings? Maybe there is an alternative way to do it. Can you post the contents of your .reg file here?
 
Well what it is, we have a mattec production server that sometimes employees need to view the last, oh lets say, 100 jobs done on a certian machine. Well, right now the SQL 2005 database can only be queried for the last 10,000 jobs. Well thats to many.. This is a reg edit to the local user to change the function of the key total qeuried from 10,000 to only 500. Thats the best I can explain it without knowing more details, I was just asked to find a way to distribute the reg keys to all the users without going from station to station to change them.
 
And what's the registry key that gets changed?
 
There are keys being added that arent present. So nothing being changed really.

Here it looks like this:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Mattec Corporation\Real-Time Display\Settings]
"RTDGroup1"=dword:0000270f
"RTDGroup2"=dword:0000270f
"RTDGroup3"=dword:0000270f
"RTDGroup4"=dword:0000270f
"Last500RefreshTime"=dword:00007530
"Last500AddFromLeft"=dword:00000000
"Last5003D"=dword:00000000
"Last500PointsToZoom"=dword:00000032
"Last500SpecLimits"=dword:00000001
"Last500ControlLimits"=dword:00000001
"Last500IdentifyJobs"=dword:00000001
"Last500UpperBound"=dword:00000000
"Last500LowerBound"=dword:00000000
"Last500MaxCycles"=dword:00000237
"Last500ShowToolbar"=dword:00000001
"Last500SubgroupSize"=dword:00000007
"Last500ObsPerRange"=dword:00000002
"Last500MovingRange"=dword:00000000
"Last500PointMarkers"=dword:00000001
"Last500HorzGrid"=dword:00000001
"Last500VertGrid"=dword:00000000
"ExceptionPoints"=dword:000003e8
 
Ok, so what I should do is edit this .reg file to import the keys to the HKEY_USERS\.DEFAULT instead of HKEY_CURRENT_USER because the system pulls the \.DEFAULT keys into the CURRENT_USER registry during login. At least I think this is what you are saying??
 
Well that didnt work as well. When i'm logging in as Admin, I have no problem at all. When logging in as a common domain user, it prompts for administrative password and even then it dont really import the keys as expected. Again when doing this under administrator its no problem.

I tried porkchopexpress's suggetions and my system didnt like the first program at all. Said it wasnt a good windows image or something (different problem different time).
 
Really, I would look into using a method I mentioned earlier. Log into one pc on your network with admin priveleges, and use a program that can manipulate remote registries, such as reg.exe. This way you are not using the user's credentials. It does not sound like this is something you need to do each time the user logs in.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top