Solved Import Reg File: cmd works - Reg\Regedit w/bat file doesn't work?

KapaKai5O

New member
Member
Local time
1:00 AM
Messages
43
This is embarrassing but I've spent so many hours on it I feel I have no choice. :o
I'm not real keen with Win 7 yet and I've done this with earlier os's without this problem.
Can't figure out why it's not working here, and I see many others having similar questions.
OS = Win7 Pro 32 bit.

I'm used to keyboard\cmd prompt so it's not an issue for me, but I'm putting together a system
for a friend who isn't that 'cmd prompt savvy'.

I need to create simple batch files for deleting and importing reg value (hklm\software\xxxx\run).
The program I'm trying to manage has no way to prevent auto running within it's gui
so I have allow the user to do this manually.
It's a FW so it's important to be able to manage it for troubleshooting etc.
It can be temporarily disabled, but it's important to prevent it from auto running as well.

When I run either 'reg.exe import autorun.reg', noautorun.reg' OR 'regedit /s autorun.reg' etc.,
via command line from the folder the reg files are in, it works perfectly every time.
But no matter how I create the bat files, they run with no prompt, no error(s) and do nothing.
Even when run as admin.

Can someone please explain what I am missing here?
I've read in a very dated thread here where someone claimed it worked by adding:
'rundll32.exe USER32.DLL, UpdatePerUserSysetmParameters ,1 ,True'
but I don't recall ever having to do this with a simple reg file import or value deletion.

I realize that Mark R's Autoruns would do the trick, but I need it to be a one click solution,
so it's very simple for user.

Thanks very much for any help on this!
 

My Computer My Computer

At a glance

Win 7 Pro 32bit - XP & W2K3 Server - Linuxi716 GBRadeon HD 7800 Series
Computer type
PC/Desktop
Computer Manufacturer/Model Number
ASUS - Home Built
OS
Win 7 Pro 32bit - XP & W2K3 Server - Linux
CPU
i7
Motherboard
Intel
Memory
16 GB
Graphics Card(s)
Radeon HD 7800 Series
Sound Card
Asus Xonar
Monitor(s) Displays
Asus
Hard Drives
SSD - Samsung EVO 1 TB + WD 2 TB x 4
PSU
EVGA G3 1000
Case
Thermaltake Level 10 GT
Cooling
Lots
Keyboard
Logitech
Mouse
MX Master 3
Internet Speed
1GB
Antivirus
Never
Browser
Pale Moon & Ungoogled Chromium, Brave etc.
Other Info
I thank you for this impressive forum
You should use the cmd regedit /s autorun.reg.

Look a winpatrol that stops any new software adding to start it ask for permission to let it start it does so much more blocks virus from starting and lets you edit start very simply
 

My Computer My Computer

At a glance

win 8 32 bit
Computer type
PC/Desktop
OS
win 8 32 bit
You should use the cmd regedit /s autorun.reg.
Thanks for the response.
Are you implying that it's not possible to setup a batch file for this simple purpose with W7?
As I wrote above, user is not wanting to type in cmd prompt.

If that's the case, I'll have no choice but to create direct shortcuts to the reg files.
And user will have to click ok on the warning every time reg file runs. I wanted to avoid that route.
Look a winpatrol that stops any new software adding to start it ask for permission to let it start it does so much more blocks virus from starting and lets you edit start very simply
?????
 

My Computer My Computer

At a glance

Win 7 Pro 32bit - XP & W2K3 Server - Linuxi716 GBRadeon HD 7800 Series
Computer type
PC/Desktop
Computer Manufacturer/Model Number
ASUS - Home Built
OS
Win 7 Pro 32bit - XP & W2K3 Server - Linux
CPU
i7
Motherboard
Intel
Memory
16 GB
Graphics Card(s)
Radeon HD 7800 Series
Sound Card
Asus Xonar
Monitor(s) Displays
Asus
Hard Drives
SSD - Samsung EVO 1 TB + WD 2 TB x 4
PSU
EVGA G3 1000
Case
Thermaltake Level 10 GT
Cooling
Lots
Keyboard
Logitech
Mouse
MX Master 3
Internet Speed
1GB
Antivirus
Never
Browser
Pale Moon & Ungoogled Chromium, Brave etc.
Other Info
I thank you for this impressive forum
I gave you the code for batch file regedit /s autorun.reg
 

My Computer My Computer

At a glance

win 8 32 bit
Computer type
PC/Desktop
OS
win 8 32 bit
I have no problem running regedit /s path_to_something.reg from a batch file.

You have a strange issue, it seems.

I see many others having similar questions.

Where? Do you have links?
 

My Computers My Computers

  • At a glance

    7 X64i5 84002x8gb 3200mhz
    Computer type
    PC/Desktop
    OS
    7 X64
    CPU
    i5 8400
    Motherboard
    gigabyte b365m ds3h
    Memory
    2x8gb 3200mhz
    Hard Drives
    various
    PSU
    pure power 11 400w cm
    Case
    Coolermaster
    Cooling
    cryorig m9i
  • At a glance

    7x64g54008gb ddr4 2400
    Computer type
    PC/Desktop
    OS
    7x64
    CPU
    g5400
    Motherboard
    ga b365m ds3h
    Memory
    8gb ddr4 2400
    PSU
    xfx pro 450w
If I'm going to add something to, or edit, my registry, I use a .reg script and NOT a batch file.

That's much less problematical.

Example of a Windows 7 registry tweak: file name, "Win-7 Performance Tweak.reg"

Windows Registry Editor Version 5.00
; Shorten shutdown time. Time is in Milliseconds.
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control]
"WaitToKillServiceTimeout"="1000"

; Load the Kernel into RAM on boot, for faster running.
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management]
"DisablePagingExecutive"="1"
"LargeSystemCache"="1"


I have a whole library of such .reg scripts, that I use when setting up a new PC or tuning up an old one.

Cheers Mates!
TechnoMage :cool:
 

My Computer My Computer

At a glance

Win 7 Pro, SP1, x86, Win-11/Pro/64AMD8GB CrucialVarious
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Various
OS
Win 7 Pro, SP1, x86, Win-11/Pro/64
CPU
AMD
Motherboard
Various
Memory
8GB Crucial
Graphics Card(s)
Various
Sound Card
OnBoard
Monitor(s) Displays
Acer 21.5"
Hard Drives
Crucial SSD, 500 GB
PSU
OEM
Case
SFF Slim Line Case
Cooling
OEM
Keyboard
eMachines
Mouse
Logitech Wireless
Internet Speed
varies
Antivirus
Windows Defender/Super Anti-Spyware
Browser
Firefox
I gave you the code for batch file regedit /s autorun.reg
Sorry, didn't understand. It's because that's exactly what I've been trying to do.
 

My Computer My Computer

At a glance

Win 7 Pro 32bit - XP & W2K3 Server - Linuxi716 GBRadeon HD 7800 Series
Computer type
PC/Desktop
Computer Manufacturer/Model Number
ASUS - Home Built
OS
Win 7 Pro 32bit - XP & W2K3 Server - Linux
CPU
i7
Motherboard
Intel
Memory
16 GB
Graphics Card(s)
Radeon HD 7800 Series
Sound Card
Asus Xonar
Monitor(s) Displays
Asus
Hard Drives
SSD - Samsung EVO 1 TB + WD 2 TB x 4
PSU
EVGA G3 1000
Case
Thermaltake Level 10 GT
Cooling
Lots
Keyboard
Logitech
Mouse
MX Master 3
Internet Speed
1GB
Antivirus
Never
Browser
Pale Moon & Ungoogled Chromium, Brave etc.
Other Info
I thank you for this impressive forum
Searching Reveals Plenty of People

I have no problem running regedit /s path_to_something.reg from a batch file.
Is it possible you could post it?
You have a strange issue, it seems. Where? Do you have links?
Too many to post. I searched and found numerous references on stack overflow and others.
 
Last edited:

My Computer My Computer

At a glance

Win 7 Pro 32bit - XP & W2K3 Server - Linuxi716 GBRadeon HD 7800 Series
Computer type
PC/Desktop
Computer Manufacturer/Model Number
ASUS - Home Built
OS
Win 7 Pro 32bit - XP & W2K3 Server - Linux
CPU
i7
Motherboard
Intel
Memory
16 GB
Graphics Card(s)
Radeon HD 7800 Series
Sound Card
Asus Xonar
Monitor(s) Displays
Asus
Hard Drives
SSD - Samsung EVO 1 TB + WD 2 TB x 4
PSU
EVGA G3 1000
Case
Thermaltake Level 10 GT
Cooling
Lots
Keyboard
Logitech
Mouse
MX Master 3
Internet Speed
1GB
Antivirus
Never
Browser
Pale Moon & Ungoogled Chromium, Brave etc.
Other Info
I thank you for this impressive forum
Could You Possibly Post One?

If I'm going to add something to, or edit, my registry, I use a .reg script and NOT a batch file.

That's much less problematical.

Example of a Windows 7 registry tweak: file name, "Win-7 Performance Tweak.reg"

Windows Registry Editor Version 5.00
; Shorten shutdown time. Time is in Milliseconds.
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control]
"WaitToKillServiceTimeout"="1000"

; Load the Kernel into RAM on boot, for faster running.
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management]
"DisablePagingExecutive"="1"
"LargeSystemCache"="1"


I have a whole library of such .reg scripts, that I use when setting up a new PC or tuning up an old one.

Cheers Mates!
TechnoMage :cool:
Could you possibly post ones to simply add & remove program from:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run ?

I can create simple .reg files for this but again, user will need to ok for permission to run.
Wouldn't scripts be the same? I'm trying to avoid user having to ok to run it.
Sorry if I am not getting this, it's been quite awhile.

Can't thank you enough for your help!
 

My Computer My Computer

At a glance

Win 7 Pro 32bit - XP & W2K3 Server - Linuxi716 GBRadeon HD 7800 Series
Computer type
PC/Desktop
Computer Manufacturer/Model Number
ASUS - Home Built
OS
Win 7 Pro 32bit - XP & W2K3 Server - Linux
CPU
i7
Motherboard
Intel
Memory
16 GB
Graphics Card(s)
Radeon HD 7800 Series
Sound Card
Asus Xonar
Monitor(s) Displays
Asus
Hard Drives
SSD - Samsung EVO 1 TB + WD 2 TB x 4
PSU
EVGA G3 1000
Case
Thermaltake Level 10 GT
Cooling
Lots
Keyboard
Logitech
Mouse
MX Master 3
Internet Speed
1GB
Antivirus
Never
Browser
Pale Moon & Ungoogled Chromium, Brave etc.
Other Info
I thank you for this impressive forum
From a huge .cmd file, here is a relevant section


Code:
@echo off
SET TP=%~dp0
SET TP=%TP:~0,-1%
cd /d "%TP%"
mode con lines=40 cols=100
color 5f

 reg.exe import "BIN\REG64\VC90x64.reg" >nul

pause
 

My Computers My Computers

  • At a glance

    7 X64i5 84002x8gb 3200mhz
    Computer type
    PC/Desktop
    OS
    7 X64
    CPU
    i5 8400
    Motherboard
    gigabyte b365m ds3h
    Memory
    2x8gb 3200mhz
    Hard Drives
    various
    PSU
    pure power 11 400w cm
    Case
    Coolermaster
    Cooling
    cryorig m9i
  • At a glance

    7x64g54008gb ddr4 2400
    Computer type
    PC/Desktop
    OS
    7x64
    CPU
    g5400
    Motherboard
    ga b365m ds3h
    Memory
    8gb ddr4 2400
    PSU
    xfx pro 450w
/s on regedit runs it silent so no need for user to do anything
 

My Computer My Computer

At a glance

win 8 32 bit
Computer type
PC/Desktop
OS
win 8 32 bit
Thanks for everyone's input and suggestions.

I'm familiar with the /S switch but unfortunately, it seems I can't import .reg files with any .cmd or .bat files.
I've tried 'reg.exe import' and 'regedit /s' , nothing works except manually typing in cmd prompt or running the .reg files directly.

I've never run into anything like this. :mad:

I'll try to read\export key and see if that's possible.
 
Last edited:

My Computer My Computer

At a glance

Win 7 Pro 32bit - XP & W2K3 Server - Linuxi716 GBRadeon HD 7800 Series
Computer type
PC/Desktop
Computer Manufacturer/Model Number
ASUS - Home Built
OS
Win 7 Pro 32bit - XP & W2K3 Server - Linux
CPU
i7
Motherboard
Intel
Memory
16 GB
Graphics Card(s)
Radeon HD 7800 Series
Sound Card
Asus Xonar
Monitor(s) Displays
Asus
Hard Drives
SSD - Samsung EVO 1 TB + WD 2 TB x 4
PSU
EVGA G3 1000
Case
Thermaltake Level 10 GT
Cooling
Lots
Keyboard
Logitech
Mouse
MX Master 3
Internet Speed
1GB
Antivirus
Never
Browser
Pale Moon & Ungoogled Chromium, Brave etc.
Other Info
I thank you for this impressive forum
Exporting is no problem - only importing or adding.
Tried Reg ADD but it recreated main key (HKLM\Software\...... Run). :o
Can't remember how to ADD via Reg.exe it's been that long.
Only need to add the entry for auto running or not auto running a program with windows start.
Import probably would work better for that? But ADD would allow direct input of value\data which works.

Any ideas how to reg add when RUN key is already present?
 

My Computer My Computer

At a glance

Win 7 Pro 32bit - XP & W2K3 Server - Linuxi716 GBRadeon HD 7800 Series
Computer type
PC/Desktop
Computer Manufacturer/Model Number
ASUS - Home Built
OS
Win 7 Pro 32bit - XP & W2K3 Server - Linux
CPU
i7
Motherboard
Intel
Memory
16 GB
Graphics Card(s)
Radeon HD 7800 Series
Sound Card
Asus Xonar
Monitor(s) Displays
Asus
Hard Drives
SSD - Samsung EVO 1 TB + WD 2 TB x 4
PSU
EVGA G3 1000
Case
Thermaltake Level 10 GT
Cooling
Lots
Keyboard
Logitech
Mouse
MX Master 3
Internet Speed
1GB
Antivirus
Never
Browser
Pale Moon & Ungoogled Chromium, Brave etc.
Other Info
I thank you for this impressive forum
Just wanted to again thank everyone here for their input.
Was able to knock the cobwebs out of my war torn brain and figure it out.
 

My Computer My Computer

At a glance

Win 7 Pro 32bit - XP & W2K3 Server - Linuxi716 GBRadeon HD 7800 Series
Computer type
PC/Desktop
Computer Manufacturer/Model Number
ASUS - Home Built
OS
Win 7 Pro 32bit - XP & W2K3 Server - Linux
CPU
i7
Motherboard
Intel
Memory
16 GB
Graphics Card(s)
Radeon HD 7800 Series
Sound Card
Asus Xonar
Monitor(s) Displays
Asus
Hard Drives
SSD - Samsung EVO 1 TB + WD 2 TB x 4
PSU
EVGA G3 1000
Case
Thermaltake Level 10 GT
Cooling
Lots
Keyboard
Logitech
Mouse
MX Master 3
Internet Speed
1GB
Antivirus
Never
Browser
Pale Moon & Ungoogled Chromium, Brave etc.
Other Info
I thank you for this impressive forum
Was able to knock the cobwebs out of my war torn brain and figure it out.

Please tell me how you did it.

I am on the verge of just converting my .reg script to a .bat version and using reg add because importing the .reg file via .bat (using regedit /s) is not working. It applies fine if I manually run the reg file, but I am having the same problem you were having.

EDIT: Found at Technet:

Code:
"ok, it's weird but I think I worked it out. Windows 7 won't merge
a .reg file with regedit, reg or regedt32 at logon if the .reg file is
on the network during logon. It works ok after logon, though.

So, I changed our logon script to copy such files to %TEMP% and
apply from there and now it works ok.

I do often wonder why Microsoft do such things..."

Code:
https://social.technet.microsoft.com/Forums/windows/en-US/43b385b5-289d-49a0-92b5-7006fe6a612d/regeditexe-fails-to-merge-reg-files-during-user-logon?forum=w7itprogeneral

I'll try doing xcopy to %TEMP% and see if it can be run from there. :rolleyes:
 
Last edited:

My Computer My Computer

At a glance

Windows 10 x64
Computer type
PC/Desktop
OS
Windows 10 x64
Back
Top