Site Maintenance this evening The site will be offline for hosting changes. Time TBC

+ Post New Thread
Results 1 to 10 of 10
Scripts Thread, Batch file to edit registry in Coding and Web Development; I am looking to make a batch file that will prompt for 2 values and then insert those 2 different ...
  1. #1

    Join Date
    Apr 2010
    Location
    St. Louis
    Posts
    4
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Batch file to edit registry

    I am looking to make a batch file that will prompt for 2 values and then insert those 2 different values (both numbers) into 2 existing registry values.

    A quick googling returned a lot of confusing scenarios. Is this possible?

  2. #2
    danrhodes's Avatar
    Join Date
    Sep 2008
    Location
    Wath Upon Dearne
    Posts
    1,513
    Thank Post
    157
    Thanked 181 Times in 150 Posts
    Rep Power
    68
    Do you have to prompt for the number or can you just import the keys?

    D

  3. #3
    superfletch's Avatar
    Join Date
    Nov 2007
    Location
    South
    Posts
    434
    Thank Post
    146
    Thanked 77 Times in 61 Posts
    Rep Power
    31
    Slightly different answer to what you are asking for but.

    1)If you have a Windows Server, (assuming you know the values) you can do this through Group Policy and it will be quicker/easier.

    2)VBS or AutoIt would be better than batch file.

    Something like this in AutoIt would get you started with an app that would prompt you for the values.





    GUICreate("Registry Changer")

    $RegHive1 = GUICtrlCreateInput("Reg Hive 1",50,50)
    $Key1 = GUICtrlCreateInput("Key 1",50,65)
    $RegHive2 = GUICtrlCreateInput("Reg Hive 2",50,80)
    $Key1 = GUICtrlCreateInput("Key 1",50,95)


    $Value_I_Set1 = GUICtrlCreateInput("What I want to set key 1 to.")
    $Value_I_Set2 = GUICtrlCreateInput("What I want to set key 2 to")

    RegWrite ( $RegHive1, $Key1 , $Value_I_Set1)
    RegWrite ( $RegHive2, $Key2 , $Value_I_Set2)

    While 1
    $msg = guigetmsg()
    Select

    CASE


    CASE
    Last edited by superfletch; 1st April 2010 at 10:01 PM. Reason: Add stuff + spelling

  4. #4

    Join Date
    Apr 2010
    Location
    St. Louis
    Posts
    4
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Thanks for the fast responses.

    The 2 registry values I want to change I dont need input for, just their values.

    So would I change the line "$RegHive1 = GUICtrlCreateInput("Reg Hive 1",50,50)" to the registry path? (i.e. "HKEY_LOCAL_MACHINE\SOFTWARE\TEST")

  5. #5

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,808
    Thank Post
    272
    Thanked 1,135 Times in 1,031 Posts
    Rep Power
    349
    Check out these support articles Importing registry keys using Reg import

    the way i do things is.
    1. edit one machine manually
    2. export the relevant edited registry settings
    3. create a batch file which says
    Code:
    reg import settings.reg
    4. add to group policy for machine startup script

    sit back and relax

    Toby

  6. #6

    Join Date
    Apr 2010
    Location
    St. Louis
    Posts
    4
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    That would be awesome glennda but my scenario is a little different.

    I am burning an image and when I boot it for the first time I need to change to specific reg values.

    The problem is I have to do this like 10 times a day. And the values are different at each site.

  7. #7

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,808
    Thank Post
    272
    Thanked 1,135 Times in 1,031 Posts
    Rep Power
    349
    what type of image are you burning?

  8. #8

    Join Date
    Apr 2010
    Location
    St. Louis
    Posts
    4
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    I am going to use clonezilla. I havent really messed with that part yet but a colleague of mine is going to help.

  9. #9


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,588
    Thank Post
    228
    Thanked 856 Times in 735 Posts
    Rep Power
    296
    probably easiest way is to set up a bunch of correct reg files so site1.reg, site2.reg etc and then just create a dos menu using choice and then just regedit /s

    something like this

    Code:
    cls
    @echo off
    goto menu
    :menu
    echo.
    echo Choice
    echo.
    echo 1 site 1
    echo 2 site 2
    echo 3 site 3
    echo 4 site 4
    echo 5 site 5
    echo 6 Order a Cuppa
    echo 7 Quit
    echo.
    
    :choice
    set /P C=[1,2,3,4,5,6,7]?
    if "%C%"=="7" goto quit
    if "%C%"=="6" goto cuppa
    if "%C%"=="5" goto 5
    if "%C%"=="4" goto 4
    if "%C%"=="3" goto 3
    if "%C%"=="2" goto 2
    if "%C%"=="1" goto 1
    goto choice
    
    :1
    regedit /s "c:\site 1.reg"
    goto quit
    
    :2
    regedit /s "c:\site 2.reg"
    goto quit
    
    :3
    regedit /s "c:\site 3.reg"
    goto quit
    
    :4
    regedit /s "c:\site 4.reg"
    goto quit
    
    :5
    regedit /s "c:\site 5.reg"
    goto quit
    
    :cuppa
    start \\server\NETLOGON\laptops\youwish.bat
    goto quit
    
    :quit
    exit
    :end

  10. #10

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,754
    Thank Post
    3,265
    Thanked 1,052 Times in 973 Posts
    Rep Power
    365
    are the 2 different values going to be the same all the time ie

    value 1 = 0
    value 2 = 1

    or do they always change randomly or what exactly ?

SHARE:
+ Post New Thread

Similar Threads

  1. Edit Share permissions using batch file?
    By Crispin in forum Windows Server 2008
    Replies: 0
    Last Post: 9th September 2009, 01:05 PM
  2. Batch file to edit registry
    By Shrimpersfan in forum Scripts
    Replies: 4
    Last Post: 4th June 2009, 11:45 AM
  3. Getting a batch file to react to a registry key
    By Wheelgunr in forum Windows
    Replies: 5
    Last Post: 12th September 2008, 05:23 PM
  4. Batch file to remove registry key doesnt work
    By sidewinder in forum Windows
    Replies: 4
    Last Post: 7th December 2007, 04:48 PM
  5. Edit registry remotely?
    By SYSMAN_MK in forum Windows
    Replies: 5
    Last Post: 3rd April 2006, 11:28 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •