Import .reg file

Mabrito

Supreme [H]ardness
Joined
Dec 24, 2004
Messages
7,004
I am trying to make a .bat file with the command "REG IMPORT autologin.reg" to import a registry file. When I double click the .reg file it successfully imports the keys. However, when I execute the .bat file to do the importing of the .reg file, it doesn't work. This is on Windows 7, so when I right click the .bat file and click "Run as Administrator" I still get no success. Any ideas?

Why a .bat file? So it can be executed in this software auto installation program I making. It only executes .bats, .vbs, and .exe's.
 
Does this work?
Code:
@echo off
%systemroot%\REGEDIT.EXE blahblahblah.reg

You can add /S to hide the confirmation dialog after the import.
Might be able to go without the %systemroot% part too.
 
i dont know if this is relevant to you, but on my computer i've noticed that if i run a .bat with the option "Run As administrator", it no longer uses the current directory the bat is sitting in as the working directory.

for example
c:/users/user/Desktop/test.bat
Code:
dir
pause
when i double click this file it outputs dir for:
c:/users/user/Desktop/

however, i if i run as administrator it outputs dir for:
c:/windows/system32/

basically what im getting at is you might have to input the entire filename path of your reg, not just the filename itself.
 
Use reg.exe to do it. It comes with windows and allows you command line access to the registry. The command you're looking for is:

Code:
REG.EXE IMPORT <path_to_file>.REG


Do a reg /? and check out what you can do with the command. Some good stuff! There is even a switch to make it quite so you can run the import without any output on the screen.
 
Use reg.exe to do it. It comes with windows and allows you command line access to the registry. The command you're looking for is:

Code:
REG.EXE IMPORT <path_to_file>.REG
.

???? isn't that what he is already doing?
I am trying to make a .bat file with the command "REG IMPORT autologin.reg" to import a registry file.
 
Executed the .bat file through a command prompt and it shows a message: ERROR: Error accessing the registry.
 
Executed the .bat file through a command prompt and it shows a message: ERROR: Error accessing the registry.

did you run cmd.exe as admin?

edit: also, demon pointed out that the reg command is an exe, you still need to use a bat?
 
Back
Top