Windows 7 Importing reg file doesn't work from batch file, but works fine manually

Ninethe

Extraordinary Member
Joined
Nov 17, 2012
Messages
69
I just can't figure this out: When I import/merge a .reg file (v5 format) manually by right-clicking the file in Explorer, it works perfectly. But if I try to import the very same .reg file in a batch file, it doesn't do anything!

The .reg file is only changing keys under HKEY_USERS. Here's a sample:

Code:
Windows Registry Editor Version 5.00

[-HKEY_USERS\S-1-5-21-3499517676-2516875876-2438310748-1000\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.3g2]
[HKEY_USERS\S-1-5-21-3499517676-2516875876-2438310748-1000\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.3g2]

[HKEY_USERS\S-1-5-21-3499517676-2516875876-2438310748-1000\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.3g2\OpenWithProgids]
"VLC.3g2"=hex(0):

[HKEY_USERS\S-1-5-21-3499517676-2516875876-2438310748-1000\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.3g2\UserChoice]
"Progid"="VLC.3g2"

I'm running 64-bit Windows 7 SP1, and I've disabled UAC, and I run as Administrator, so that's not the problem.
But just in case, in the batch file I used NirSoft's NirCmd (http://www.nirsoft.net/utils/nircmd.html) to elevate the command level to run as System, as follows:
Code:
NirCmd.exe ElevateCommand RunAsSystem C:\Windows\Regedit.exe /S "PathToRegFile.reg"

But as I said, nothing in the registry gets changed from that batch file command!

(By the way, before turning to NirCmd out of desperation, it originally said just "Regedit /S "PathToRegFile.reg").

The batch file and commands work correctly under 32-bit XP Pro, but none of those batch files that import reg files work under 64-bit Windows 7!

What's going on?
 
Solution
It seems like you are encountering issues when trying to import a .reg file using a batch file on 64-bit Windows 7. The behavior you are describing suggests there might be some compatibility or permission-related issues specific to the operating system. Here are a few things you can check and try to resolve the issue:
  1. Verify the Registry Path:
    • Ensure that the registry path you are trying to modify under HKEY_USERS exists and is accurate for the user you are targeting.
    []Permissions:
    • Check the permissions on the registry keys you are trying to modify. Even though you are running as Administrator, certain keys might still have restricted access.
    [
    ]Try Running the Batch File as...
It seems like you are encountering issues when trying to import a .reg file using a batch file on 64-bit Windows 7. The behavior you are describing suggests there might be some compatibility or permission-related issues specific to the operating system. Here are a few things you can check and try to resolve the issue:
  1. Verify the Registry Path:
    • Ensure that the registry path you are trying to modify under HKEY_USERS exists and is accurate for the user you are targeting.
    []Permissions:
    • Check the permissions on the registry keys you are trying to modify. Even though you are running as Administrator, certain keys might still have restricted access.
    [
    ]Try Running the Batch File as Administrator:
    • Right-click on the batch file and select "Run as administrator" to ensure it has the necessary permissions to make changes to the registry.
    []Path to RegEdit.exe:
    • In your batch file, ensure that the path to RegEdit.exe is correct. You can try using the full path to regedit.exe (e.g., C:\Windows\regedit.exe).
    [
    ]NirCmd Usage:
    • If you are using NirCmd, ensure that the path to NirCmd.exe and the command for elevation are correct. Verify that NirCmd is functioning as expected on your system.
    []Debugging:
    • Add some echo statements in your batch file to see if the batch script is executing correctly.
    [
    ]Batch File Content:
    • Double-check the content of your batch file and make sure there are no syntax errors that might be causing the issue.
  2. Error Logs:
    • Check if there are any error logs or messages generated when running the batch file. This can provide more insights into what might be going wrong. Given the differences in behavior between 32-bit XP Pro and 64-bit Windows 7, it's possible that there are system-specific nuances causing the problem. By carefully reviewing these points and trying out the suggestions provided, you may be able to pinpoint the issue and successfully import the .reg file using a batch file on Windows 7.
 
Solution