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 strongm 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
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.
 
Yes you are right, it only needs to be imported one time, and the keys will be there for good. I will give reg.exe a shot. When ever you have a chance can you give me run down of how it works, or resouces to read about it. I never have used it so I guess I need to read about it.
 
Here's a sample, I used this to deploy WSUS settings via registry before we had AD and GPO. Not sure if it will fit in the screen, but if not, the "for /F" is the start of each new line:

Code:
for /F %%1 in (c:\list.txt) DO reg add \\%%1\HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /f
for /F %%1 in (c:\list.txt) DO reg add \\%%1\HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /v WUServer /t REG_SZ /d [URL unfurl="true"]http://svr[/URL] /f
for /F %%1 in (c:\list.txt) DO reg add \\%%1\HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /v WUStatusServer /t REG_SZ /d [URL unfurl="true"]http://srv[/URL] /f
for /F %%1 in (c:\list.txt) DO reg add \\%%1\HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU /f
for /F %%1 in (c:\list.txt) DO reg add \\%%1\HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU /v UseWUServer /t REG_DWORD /d 1 /f
for /F %%1 in (c:\list.txt) DO reg add \\%%1\HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU /v AUOptions /t REG_DWORD /d 4 /f
for /F %%1 in (c:\list.txt) DO reg add \\%%1\HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU /v ScheduledInstallDay /t REG_DWORD /d 0 /f
for /F %%1 in (c:\list.txt) DO reg add \\%%1\HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU /v ScheduledInstallTime /t REG_DWORD /d 10 /f
for /F %%1 in (c:\list.txt) DO reg add \\%%1\HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU /v NoAutoRebootWithLoggedOnUsers /t REG_DWORD /d 1 /f
for /F %%1 in (c:\list.txt) DO reg add \\%%1\HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU /v NoAutoUpdate /t REG_DWORD /d 0 /f
 
Question, I typed reg.exe into the command line and got some info back. Do I need to type all that stuff in line for line for each computer on my network. Or would I just have to type it once on my machine then export it in some way?
 
Have you ever used a for loop before?

In the code above, I have a list of computers (c:\list.txt). The FOR loop runs a command (reg add ...) against each computer in the list.
 
Ya umm, I really don't know anything about programming nor do I really want to (right now). I know the code you typed isnt programming per say, its just commands in the CLI. None the less I know nothing about it. If you tell me the FOR loop command does whatever, then ya I will know it does that. But how and where to use it I would not know that. Not sure if I have the time to learn right now either :)


I think what I am going to do is set the .reg file needed to be imported, on our network shares drive. Then I will carefully (ever so carefully) explain to all the users that its there and what the purpose of the .reg file is for us. I will then explain that if anyone feels the need for it then they can double click it and it will add those keys to there registry, and if they dont need it then dont double click it :)... I will even use pictures :)


thanks a million for your concern and help chipk !!
 
Tyarbar:

You could do a lot more with a VB Script. I know nothing about script writing myself. But with a little tinkering I have been able to take scripts that I have inherited and make changes to reflect changes in our environment.

We have a one login VB script (technically, a Windows Scripting Host script) that does everything you want done, and more. It first determines what school the user it by the 2nd octet of the IP. Then it filters through the user's security groups to determine what their primary group is - office staff, teacher, special ed, librarian, etc. From those two bits of information, it maps every drive they need based upon their school and job function. It also imports one registry key into HKEY_Current_User for a plugin to our Student Information System and and a second key for redirection of their Favorites folder. Pretty slick, eh?

If you want me to share some of how this is done, just let me know.
 
'chuck this in a .vbs file and see how you get on
Option Explicit
Dim WshShell
Set WshShell = CreateObject("Wscript.Shell")
WshShell.RegWrite "HKEY_CURRENT_USER\Software\Mattec Corporation\Real-Time Display\Settings\Last5003D", 0 ,"REG_DWORD"
WshShell.RegWrite "HKEY_CURRENT_USER\Software\Mattec Corporation\Real-Time Display\Settings\"Last500PointsToZoom", 32,"REG_DWORD"
Set WshShell = Nothing
 
i wrote something to replace some citrix user profile stuff.
simple dll using Windows API calls to update the registry.
the dll read flat files which contained the registry hives to import and export.
it is much quicker and easier to maintain than regedit or keeping the actual data with your computation (what i have shown above) vbscript is just as powerful as the dll/api approach, i.e you could read in text files and write them out when the user logs off (roaming profile type of stuff) but wont be as fast as the api approach
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top