Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: auto-merge .reg @boot

13 Jul 2010   #1
wahnsinn

W7 Pro x86
 
 
auto-merge .reg @boot

Hi,
Is it possible to have my w7 Pro x64 automatically merge a .reg file into the registry at every boot (or, on every login if thats easier.. I only use one account so far).
(Its supposed to clear a bunch of history and MRU entries and those sort of things).

In XP i used to do it via .bat file, but there has to be a more elegant solution, I figure

thanks in advance


My System SpecsSystem Spec
.

13 Jul 2010   #2
TimStitt

Windows 7 Ultimate 64 bit
 
 

Hi wahnsinn,

I too would use a batch file and I'd s also use the windows scheduler with triggers to set it so that it runs automatically.

I can't think of any "more elegant" way.

- Timo
My System SpecsSystem Spec
13 Jul 2010   #3
Dwarf

Windows 8.1 Pro RTM x64
 
 

Hi wahnsinn,

If the batch file works, then there is no reason to change it.

What you can do is to arrange for it to execute automatically and, instead of using the Task Scheduler, I would suggest the following. It involves editing the Registry.

Log onto the account(s) that you wish execute the batch file on and open the Registry Editor. Next, browse to the following key:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run

In the right-hand panel, right- click and choose New > String Value. Name it Batch (or whatever you want, this doesn't matter but it is helpful to have meaningful names). Next, right-click on the new entry and choose Modify... (alternatively, double-click it). Enter the following code:

C:\<Path to batch file>\Batch.bat
My System SpecsSystem Spec
.


13 Jul 2010   #4
wahnsinn

W7 Pro x86
 
 

Thanks for your answers.
I have not actually tried the batch file on w7, but am confident it would work.
But I still feel this is a quite clumsy way of doing it, and would prefer a solution that doesnt feel so much like a work-around.

In my search for another solution I came upon the idea of using a logon script..
I know in theory how to set one up - cant script myself though, and wouldnt know how to make it merge a .reg either..
but that, I think, would be a good, elegant, solution .. maybe anyone here knows how to do that..?
My System SpecsSystem Spec
14 Jul 2010   #5
TimStitt

Windows 7 Ultimate 64 bit
 
 

Hi Wahnsinn,

Let me point you in the right direction and then you can let me know if you get stuck and I'll elaborate.

1. Create your script in vbs or Powershell.
2. Open gpedit.msc (by typing it into RUN or SEARCH and pressing ENTER)
3. Navigate to USER CONFIGURATION | WINDOWS SETTINGS | SCRIPTS | LOGON
4. Double click on LOGON to bring up the properties and link it to your script.

I'm yet to try this on Windows 7 on a stand alone install (I've set up many logon scripts via DC's), so I look forward to hearing how you go with this one.

Good Luck

Timo


Attached Thumbnails
-logon.jpg  
My System SpecsSystem Spec
25 Jul 2010   #6
wahnsinn

W7 Pro x86
 
 

Sorry for not responding sooner, I have in fact not had any time to investigate this matter any further so far!

Thanks for your response, TimStitt, but, as I pointed out earlier, I already knew HOW to add a script basically, my problem lies in your step 1. "Create your script ..."

Also, coming back to the original "batch file" thing, could it be that Windows accepts batch files as logon scripts?
I'll definitely need to check that out at some point.. that obviously would be the easiest way, and if thats what you were trying to tell me in your first post, I apologize for misunderstanding
My System SpecsSystem Spec
25 Jul 2010   #7
TimStitt

Windows 7 Ultimate 64 bit
 
 

Hi wahnsinn,

No problem of the delay in getting back. I get a notification and am happy to take it up when you're available.

However, I admit to be there being some confusion as to what you require. SO I will give you a lot of information and a few guesses here in an effort to hit the right spot!

Batch (CMD) Scripting
If you already have a batch file that imports a registry entry. Just add this as your logon script in gpedit. To answer your question, as far as I am aware 'Yes' windows accepts batch files (if you check in the adding s startup script area you'll see that the file type is "all file types"). You can easily verify this by adding your batch file, rebooting and letting us know. If this doesn't work then task scheduler would be the best move forward. When you set this up via gpedit, ensure that SYSTEM has read permissions on the file and don;t store the batch file in thes directory as this will make windows prompt for admin rights to run it.

If you wish to run a *.reg file from inside a batch, or even create the regfile during the batch file running, then we need to consider checking the registry and file permissions first, which is no big problem, but let me know and we'll take it from there.

Powershell (PS) and Visual Basic (VB) Scripting [VBS]
If you are wishing to learn another scripting language (such as VB or PS) then please say exactly that, post your batch file up so that I can see what it does (feel free to PM me if it's a file that you want to keep private) and we can talk about the next steps. However using powershell or VB is neither more or less elegant than a command script (for most functions).

Lastly, if we're not on the same page yet , please break it down to baby steps. Here's an example, feel free to edit it or write your own.

Enviroment
1. I have this script xxxxxx
2. It works in XP when added to the start menu folder
3. I am using this script in Windows 7 Ultimate 64bit and Windows 7 HP 32bit
Job Scope
I would like the script to work in the above environment with the following requirements:
1. Low installation time
2. work Automatically
3. Low maintenance
Questions
1. Is this possible?
2. Is there another method (a better method?) that I can use to configure this scenario?


-Timo
My System SpecsSystem Spec
03 Aug 2010   #8
wahnsinn

W7 Pro x86
 
 

Quote   Quote: Originally Posted by TimStitt View Post
If you already have a batch file that imports a registry entry. Just add this as your logon script in gpedit. To answer your question, as far as I am aware 'Yes' windows accepts batch files (if you check in the adding s startup script area you'll see that the file type is "all file types"). You can easily verify this by adding your batch file, rebooting and letting us know.
Thanks Tim, that works like a charm.

Quote   Quote: Originally Posted by TimStitt View Post
When you set this up via gpedit, ensure that SYSTEM has read permissions on the file and don;t store the batch file in thes directory as this will make windows prompt for admin rights to run it.

If you wish to run a *.reg file from inside a batch, or even create the regfile during the batch file running, then we need to consider checking the registry and file permissions first, which is no big problem, but let me know and we'll take it from there.
Both of these things turned out to be no problem on my system, i have the .bat stored in C:\Windows\System32\GroupPolicy\User\Scripts\Logon , the permissions of which seem to be quite heavily restricted (for example, I cannot edit the file with a text editor directly), but it runs without a hitch from that location nonetheless.

I also used a little trick I picked up on Batch files - Use REGEDIT to add, read or delete registry values, which he calls "Self-contained registry scripts":

Code:
 
registry.bat:
 
REGEDIT4
; @ECHO OFF
; CLS
; REGEDIT.EXE /S "%~f0"
; EXIT
[HKEY_CURRENT_USER\Software\Microsoft\etc]
"etc"=etcetera
..which allows for the .bat file to include the information otherwise included in the .reg


thanks again for all your help, this thread can be closed if that is the normal policy on here.
My System SpecsSystem Spec
09 Aug 2010   #9
TimStitt

Windows 7 Ultimate 64 bit
 
 

Quote   Quote: Originally Posted by wahnsinn View Post
Quote   Quote: Originally Posted by TimStitt View Post
If you already have a batch file that imports a registry entry. Just add this as your logon script in gpedit. To answer your question, as far as I am aware 'Yes' windows accepts batch files (if you check in the adding s startup script area you'll see that the file type is "all file types"). You can easily verify this by adding your batch file, rebooting and letting us know.
Thanks Tim, that works like a charm.

Quote   Quote: Originally Posted by TimStitt View Post
When you set this up via gpedit, ensure that SYSTEM has read permissions on the file and don;t store the batch file in thes directory as this will make windows prompt for admin rights to run it.

If you wish to run a *.reg file from inside a batch, or even create the regfile during the batch file running, then we need to consider checking the registry and file permissions first, which is no big problem, but let me know and we'll take it from there.
Both of these things turned out to be no problem on my system, i have the .bat stored in C:\Windows\System32\GroupPolicy\User\Scripts\Logon , the permissions of which seem to be quite heavily restricted (for example, I cannot edit the file with a text editor directly), but it runs without a hitch from that location nonetheless.

I also used a little trick I picked up on Batch files - Use REGEDIT to add, read or delete registry values, which he calls "Self-contained registry scripts":

Code:
 
registry.bat:
 
REGEDIT4
; @ECHO OFF
; CLS
; REGEDIT.EXE /S "%~f0"
; EXIT
[HKEY_CURRENT_USER\Software\Microsoft\etc]
"etc"=etcetera
..which allows for the .bat file to include the information otherwise included in the .reg


thanks again for all your help, this thread can be closed if that is the normal policy on here.
Your welcome mate and thanks for the additional info.

BTW - If you can;t edit the batch file normally in that location. Open notepad with admin privileges and then open the bat file from notepad. This usually works.

Cheers

Timo
My System SpecsSystem Spec
Reply

 auto-merge .reg @boot




Thread Tools





Similar help and support threads
Thread Forum
Merge user folders to non boot HDD
I have Win 7 Pro installed on a new SSD drive. I've been installing my programs back onto it and want to merge the my documents etc from the SSD Boot and the old boot HDD (which is temporarly removed) on another HDD in the system. What is the best way to copy all the my documents, my pictures etc...
Installation & Setup
Merge boot and system partitions
Hi all, I've recently installed a new, 2nd, hard drive on my computer which I'll be using to store data on. All went well, fairly easy installation, but this meant that I ended up playing about with partitions on my 1st HDD (the one where windows is installed). I managed to allocate my 1st...
General Discussion
Problem with Boot Manager - will not auto boot from HD
Win 7, 64 bit I recently replaced a HD due to a RAID failure. Everything mirrored properly. However, when I boot up the process stops at the Win Boot Manager. On that screen I have the choice of clicking Win 7 or Win 7 Home Premium (Recommended). If I click on Win7 Home Prem the PC boots...
Installation & Setup
how to auto boot to a program
How can I make windows auto boot to a program, without the need of using the user interface, etc I heard of something like c:/autoboot.ini Also is their a possibility I can easily make it skip Windows logo loadup sign, and go straight to the program?
General Discussion
Boot and System Partition Merge
First of all I know I'll get some answers saying use Partition Magic as I've seen them all over the web, I've tried it and I get errors when I try to launch it. I have a 500 GB hard drive that has been partitioned into 60GB and 410 GB. OS D: - System Local Disk C: - Boot Because the D...
Hardware & Devices
Merge or create partition & Dual Boot
Hi, I have 290GB free space on my Logical Drive c: (wherein resides my W7 OS). Can I: a) merge the free space into c: or b) create another partition, add another OS and then dual boot I have been reading other posts and tutorials about partitioning but have not seen a similar issue. Please...
Hardware & Devices

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 19:21.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App