At what point is regedit available?


JoshAld

New member
Local time
3:27 PM
Posts
2
Visit site
OS
Windows11
Hello All,

I'm working on a process that creates an EC2 instance running Windows Server 2022 Datacenter, installs software and then tries to add registry entries in order to set some default preferences for the software. It adds registry entries by writing a .reg file and executing it with regedit. If I run this process as part of the start up/install process, it writes the .reg file but running it doesn't add it's registry entries (it's run using AWS ssm and the command executes successfully). If I run the process after a few minutes, it will successfully edit the registry entires. My question is if anyone knows if there is a process early on in the life-cycle of the machine that may be blocking the regedit execution, or perhaps it can't be executed while another installation is active? Are there any logs anywhere to see what's happening?

I'm really at a stand-still here if anyone has any troubleshooting ideas.

Josh
 

My Computer

System One

  • OS
    Windows11
    Computer type
    PC/Desktop
I'd say that having Windows fully loaded would be the time to make a change, e.g. having all the drivers loaded and Profile settings loaded. Also, many times changes to the Registry does require rebooting to make the changes available to Windows. Other than that, I'm not a gamer nor a programmer, but others may have a solution.
 

My Computers

System One System Two

  • OS
    Win11 Pro RTM
    Computer type
    Laptop
    Manufacturer/Model
    Dell Vostro 3400
    CPU
    Intel Core i5 11th Gen. 2.40GHz
    Memory
    12GB
    Hard Drives
    256GB SSD NVMe
  • Operating System
    Windows 11 Pro RTM x64
    Computer type
    PC/Desktop
    Manufacturer/Model
    Dell Vostro 5890
    CPU
    Intel Core i5 10th Gen. 2.90GHz
    Memory
    16GB
    Graphics card(s)
    Onboard, no VGA, using a DisplayPort-to-VGA adapter
    Monitor(s) Displays
    24" Dell
    Hard Drives
    512GB SSD NVMe, 2TB WDC HDD
    Browser
    Firefox, Edge
    Antivirus
    Windows Defender/Microsoft Security
The registry is simply a datastore, and how individual apps or Windows processes react to your key's presence can vary:

- Some processes will accept any valid keys, as soon as they execute for the first time.
- Some processes (mostly security-related) may stop working because they expected to provision all their settings on first-run. And you trampled in their space.
- Some processes will do their own provisioning, and overwrite any keys you inserted beforehand.

Unless there's clear docs on the matter, it's a matter of trial & error. Sometimes you can embed reg values into an install image's registry hives, and they work. Other times you have to inject them post-install, or after the first run.
 

My Computer

System One

  • OS
    Windows 7
I might add:

- There are no exclusion locks on reg keys. Last write (or update) wins.
- There are no registry update logs.
- One debug trick is to take a series of "reg query" snapshots on the desired key/subkeys. Save the current key state to a named file before your app runs. Start the app, and if you can run another process in the background, take another snapshot. When the app's done with setup, take a third snapshot. In the absence of detailed logging, or process profiling, you can get an idea of what's happening over time. Did your pre-existing key get clobbered?
 

My Computer

System One

  • OS
    Windows 7
I might add:

- There are no exclusion locks on reg keys. Last write (or update) wins.
- There are no registry update logs.
- One debug trick is to take a series of "reg query" snapshots on the desired key/subkeys. Save the current key state to a named file before your app runs. Start the app, and if you can run another process in the background, take another snapshot. When the app's done with setup, take a third snapshot. In the absence of detailed logging, or process profiling, you can get an idea of what's happening over time. Did your pre-existing key get clobbered?


The registry I'm writing is for an application that isn't yet installed. Once the app is installed, the registries don't get overridden and are preserved.

I've read the only one instance of reg.ex can be used at a time. Is it possible that registry is already being edit, so my regedit command gets ignored? If that's the case, is there a way to way for regedit to be available?

Thanks for the help, by the way!
 

My Computer

System One

  • OS
    Windows11
    Computer type
    PC/Desktop
Years ago there was a registry backup change.

Microsoft had modified the default settings.

The settings can be modified to see if there is any impact.

 

My Computer

System One

  • OS
    Windows 10
    Computer type
    Laptop
    Manufacturer/Model
    HP
    CPU
    Intel(R) Core(TM) i7-4800MQ CPU @ 2.70GHz
    Motherboard
    Product : 190A Version : KBC Version 94.56
    Memory
    16 GB Total: Manufacturer : Samsung MemoryType : DDR3 FormFactor : SODIMM Capacity : 8GB Speed : 1600
    Graphics Card(s)
    NVIDIA Quadro K3100M; Intel(R) HD Graphics 4600
    Sound Card
    IDT High Definition Audio CODEC; PNP Device ID HDAUDIO\FUNC_01&VEN_111D&DEV_76E0
    Hard Drives
    Model Hitachi HTS727575A9E364
    Antivirus
    Microsoft Defender
    Other Info
    Mobile Workstation
Most apps or their installers don't use reg.exe or regedit, they use direct API calls to update the registry. There is no concept of exclusive locks for Registry. It's a datastore, and not a database. Last write wins.

This really boils down to the software devs. When you make a write to the registry, your API may inform you that a key already exists. A smart dev will think about how to handle this case. Some devs don't really care, and force overwrite keys (or even delete any previous entries) just to guarantee a clean environment for their app. When you're making a Task Sequence to install apps, you have to figure out a way to insert your reg key before the app starts. Or if possible, install the app but not have it auto-start. Then configure it to auto-start.
 

My Computer

System One

  • OS
    Windows 7
Are there any logs anywhere to see what's happening?
There's a Win32 API function which you can use to be notified of when a key has been changed: RegNotifyChangeKeyValue function (winreg.h) - Win32 apps

Alternatively, you could look at using Sysmon? Sysmon - Sysinternals

There is no concept of exclusive locks for Registry. It's a datastore, and not a database. Last write wins.
I don't think that is the case, from a dump file I've been looking at, there does seem to be a registry lock: nt!CmpIsRegistryLockAcquired. I doubt this is publicly exposed though since it is a private function.
 

My Computer

System One

  • OS
    Windows 11, Windows 10, Linux Fedora Cinnamon
Hello All,

I'm working on a process that creates an EC2 instance running Windows Server 2022 Datacenter, installs software and then tries to add registry entries in order to set some default preferences for the software. It adds registry entries by writing a .reg file and executing it with regedit. If I run this process as part of the start up/install process, it writes the .reg file but running it doesn't add it's registry entries (it's run using AWS ssm and the command executes successfully). If I run the process after a few minutes, it will successfully edit the registry entires. My question is if anyone knows if there is a process early on in the life-cycle of the machine that may be blocking the regedit execution, or perhaps it can't be executed while another installation is active? Are there any logs anywhere to see what's happening?

I'm really at a stand-still here if anyone has any troubleshooting ideas.

Josh

One thing you could try, since this is an EC2 instance, is to install the software, then write to the registry, assuming the install is not instantaneous, and that enough time has passed to allow writing to the registry.

If the installation creates its own default set of items that you don't want, remove the entire hive for that software by prefacing the generated .reg file with a -[main hive name] at the top, removing all the settings it created.

If, OTOH, you're writing only certain keys and don't want the rest of the hive for that software removed, have the file that you generate first delete any existing key that you're about to write, before writing your own key, so it is exactly as you want. You'd do it similarly as above, except for every key you create, you first create the deletion:

Code:
-[HKCU\XXX\yyy\key]

+[HKCU\XXX\yyy\key]
 

My Computers

System One System Two

  • OS
    Windows 11 23H2 Current build
    Computer type
    PC/Desktop
    Manufacturer/Model
    HomeBrew
    CPU
    AMD Ryzen 9 3950X
    Motherboard
    MSI MEG X570 GODLIKE
    Memory
    4 * 32 GB - Corsair Vengeance 3600 MHz
    Graphics Card(s)
    EVGA GeForce RTX 3080 Ti XC3 ULTRA GAMING (12G-P5-3955-KR)
    Sound Card
    Realtek® ALC1220 Codec
    Monitor(s) Displays
    2x Eve Spectrum ES07D03 4K Gaming Monitor (Matte) | Eve Spectrum ES07DC9 4K Gaming Monitor (Glossy)
    Screen Resolution
    3x 3840 x 2160
    Hard Drives
    3x Samsung 980 Pro NVMe PCIe 4 M.2 2 TB SSD (MZ-V8P2T0B/AM) } 3x Sabrent Rocket NVMe 4.0 1 TB SSD (USB)
    PSU
    PC Power & Cooling’s Silencer Series 1050 Watt, 80 Plus Platinum
    Case
    Fractal Design Define 7 XL Dark ATX Full Tower Case
    Cooling
    NZXT KRAKEN Z73 73.11 CFM Liquid CPU Cooler (3x 120 mm push top) + Air 3x 140mm case fans (pull front) + 1x 120 mm (push back) and 1 x 120 mm (pull bottom)
    Keyboard
    SteelSeries Apex Pro Wired Gaming Keyboard
    Mouse
    Logitech MX Master 3S | MX Master 3 for Business
    Internet Speed
    AT&T LightSpeed Gigabit Duplex Ftth
    Browser
    Nightly (default) + Firefox (stable), Chrome, Edge
    Antivirus
    Defender + MB 5 Beta
  • Operating System
    ChromeOS Flex Dev Channel (current)
    Computer type
    Laptop
    Manufacturer/Model
    Dell Latitude E5470
    CPU
    Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz, 2501 Mhz, 2 Core(s), 4 Logical Processor(s)
    Motherboard
    Dell
    Memory
    16 GB
    Graphics card(s)
    Intel(R) HD Graphics 520
    Sound Card
    Intel(R) HD Graphics 520 + RealTek Audio
    Monitor(s) Displays
    Dell laptop display 15"
    Screen Resolution
    1920 * 1080
    Hard Drives
    Toshiba 128GB M.2 22300 drive
    INTEL Cherryville 520 Series SSDSC2CW180A 180 GB SATA III SSD
    PSU
    Dell
    Case
    Dell
    Cooling
    Dell
    Mouse
    Logitech MX Master 3S (shared w. Sys 1) | Dell TouchPad
    Keyboard
    Dell
    Internet Speed
    AT&T LightSpeed Gigabit Duplex Ftth

Latest Support Threads

Back
Top Bottom