auto-merge .reg @boot


  1. Posts : 27
    W7 Pro x64
       #1

    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 Computer


  2. Posts : 1,020
    Windows 7 Ultimate 64 bit
       #2

    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 Computer


  3. Posts : 9,582
    Windows 8.1 Pro RTM x64
       #3

    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 Computer


  4. Posts : 27
    W7 Pro x64
    Thread Starter
       #4

    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 Computer


  5. Posts : 1,020
    Windows 7 Ultimate 64 bit
       #5

    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 Attached Thumbnails auto-merge .reg @boot-logon.jpg  
      My Computer


  6. Posts : 27
    W7 Pro x64
    Thread Starter
       #6

    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 Computer


  7. Posts : 1,020
    Windows 7 Ultimate 64 bit
       #7

    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 Computer


  8. Posts : 27
    W7 Pro x64
    Thread Starter
       #8

    TimStitt said:
    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.

    TimStitt said:
    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 Computer


  9. Posts : 1,020
    Windows 7 Ultimate 64 bit
       #9

    wahnsinn said:
    TimStitt said:
    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.

    TimStitt said:
    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 Computer


 

  Related Discussions
Our Sites
Site Links
About 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 15:42.
Find Us