Trying to combine a batch file with a reg add.

Rick Someone 411 Reputation points
2020-11-16T15:54:41.257+00:00

I have an autologin bat file which just asks what the pc name is. That works fine.

What I'd like it to also do is:

change the autoadminlogon to 1, change the defaultpassword.

I can do this in two files, a batch file to add the pc name, like this:

@Echo off
echo.
set /p name="Please enter new Testing Name: "

then I would like it to kick off a reg import that I exported with all of my changes. It only changes

HKLM\SOFTWARE\Microsoft\Windows NT\Current Version\Winlogon

The Winlogon is the reg I exported. If I manually MERGE it, it populates all the fields I need in that reg entry. Id like to have the above batch file run (add the pc name) and also MERGE the reg all in one task.
How would I go about having the bat file do what it does, then also merge that reg entry?
Thanks!

Microsoft Deployment Toolkit
Microsoft Deployment Toolkit
A collection of Microsoft tools and documentation for automating desktop and server deployment. Previously known as Microsoft Solution Accelerator for Business Desktop Deployment (BDD).
833 questions
0 comments No comments
{count} votes

Accepted answer
  1. Rick Someone 411 Reputation points
    2020-11-20T14:04:55.617+00:00

    What I've found is that for me to add a few reg's I had to use regedit.exe /D? regname.reg
    Another entry I had to use reg ad "HKCU...…"

    and in that file I am also adding C++ Redistributablexxxx.exe and I am using
    Start C:\location of C++ file /q

    So my batch file now imports a reg, adds a reg entry and installs C++.


1 additional answer

Sort by: Most helpful
  1. Oliver Kieselbach 241 Reputation points MVP
    2020-11-17T08:15:03.31+00:00

    Hey @Rick Someone ,

    just use reg import for it. I specified to explicitly use the x64 registry hive and redirected the output to nul to not show any output in this case:

    @echo off  
    echo.  
    set /p name="Please enter new Testing Name: "  
    reg import "C:\path-to-your-reg-file\import.reg" /reg:64 2> nul  
    

    best,

    ---
    Oliver Kieselbach | Twitter | Blog
    Mark useful answers by clicking "Accept Answer", many thanks!

    0 comments No comments