how can I execute a reg file via bat cmd or power without any dialog confirmation ?


Recommended Posts

From a brief search to verify... I believe that you can do it by using the "/s" flag (without the quotes... ie: 

regedit.exe /s "registrysetting.reg"

You don't "run" a reg file, you import it - using regedit.exe - the only reason double-clicking it works is because the file association is there to import it using regedit.exe

So as noted above, you can call the regedit executable with the correct arguments to import it.

PowerShell ftw...

Fill in the variables, save as <filename>.ps1

$RegistryPath = ""
$Name = ""
$Value = ""
$PropertyType = ""
if (!(Test-Path $RegistryPath)) {
    New-Item -Path $RegistryPath -Force | Out-Null
    New-ItemProperty -Path $RegistryPath -Name $Name -Value $Value -PropertyType $PropertyType -Force
}
else {
    New-ItemProperty -Path $RegistryPath -Name $Name -Value $Value -PropertyType $PropertyType -Force
}

 

reg import nameoffile.reg

You should be able to drop this in a powershell script (.ps1) without any hassle. It does not prompt for confirmation, but I believe it must be run with either elevated permissions or a user that has write access to the registry.

Details can be found here: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/reg-import

Edited by satukoro
clarified required permissions
  On 08/02/2024 at 09:40, Sulphy said:

From a brief search to verify... I believe that you can do it by using the "/s" flag (without the quotes... ie: 

regedit.exe /s "registrysetting.reg"
Expand  

Hi

thanks it works perfectly without any confirmation

  On 08/02/2024 at 13:24, satukoro said:
reg import nameoffile.reg

You should be able to drop this in a powershell script (.ps1) without any hassle. It does not prompt for confirmation, but I believe it must be run with either elevated permissions or a user that has write access to the registry.

Details can be found here: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/reg-import

Expand  

hi

i have only to save as start.ps1 and without the "c:\documents\test.reg" ?

thanks

  On 08/02/2024 at 11:54, binaryzero said:

PowerShell ftw...

Fill in the variables, save as <filename>.ps1

$RegistryPath = ""
$Name = ""
$Value = ""
$PropertyType = ""
if (!(Test-Path $RegistryPath)) {
    New-Item -Path $RegistryPath -Force | Out-Null
    New-ItemProperty -Path $RegistryPath -Name $Name -Value $Value -PropertyType $PropertyType -Force
}
else {
    New-ItemProperty -Path $RegistryPath -Name $Name -Value $Value -PropertyType $PropertyType -Force
}

 

Expand  

hi

may i know which are the variables ? I should only add the location file

thanks

  On 09/02/2024 at 14:19, drugo said:

i have only to save as start.ps1 and without the "c:\documents\test.reg" ?

thanks

Expand  

It depends on how you are trying to execute this command. If you are trying to simply import the .reg file on a schedule, like with a scheduled task, you could configure the scheduled task with powershell.exe in the "program" field and the following into the "arguments" field:

-command "reg import c:\path\to\reg\file.reg"

Alternatively, if you wanted to create a .ps1 powershell script to execute this command as needed, you would create and blank .ps1 file in a text editor and add the following line:

reg import "c:\path\to\reg\file.reg"

*Note: quotes are only required if your file path has spaces in it

*Note 2: If you are not running signed powershell scripts you will need to bypass or set your executionpolicy. This can be done by running a command in an administrative powershell window, however I will let you decide if you want to pursue that route.

I just tend to use this, as we had to find a way to execute reg files a few years back for intune only devices.

 

https://reg2ps.azurewebsites.net/

  On 09/02/2024 at 14:19, drugo said:

hi

may i know which are the variables ? I should only add the location file

thanks

Expand  

The variables are the lines that start with $.. Look in your reg file, fill the values in.

As ^ suggested, https://reg2ps.azurewebsites.net/ is rockin 🤘.

 

  On 09/02/2024 at 15:36, Ahazuarus said:

not sure why no one is recommending this?  Just a simple converter utility (linked below) that gives a couple of different ways to do it.

https://www.sordum.org/8478/reg-converter-v1-2/

Expand  

Hi

seems a nice program

thanks

  On 09/02/2024 at 16:53, satukoro said:

It depends on how you are trying to execute this command. If you are trying to simply import the .reg file on a schedule, like with a scheduled task, you could configure the scheduled task with powershell.exe in the "program" field and the following into the "arguments" field:

-command "reg import c:\path\to\reg\file.reg"

Alternatively, if you wanted to create a .ps1 powershell script to execute this command as needed, you would create and blank .ps1 file in a text editor and add the following line:

reg import "c:\path\to\reg\file.reg"

*Note: quotes are only required if your file path has spaces in it

*Note 2: If you are not running signed powershell scripts you will need to bypass or set your executionpolicy. This can be done by running a command in an administrative powershell window, however I will let you decide if you want to pursue that route.

Expand  

hi

important are note 1 and 2!

thanks

  On 09/02/2024 at 17:28, strotee said:
powershell -c "saps -FilePath $env:windir\regedit.exe -Argumentlist @('/s', 'path_to_your_reg_file.reg')"

 

Expand  

Hi

another great powershell command line , i guess i should learn powershell

thanks

  On 09/02/2024 at 18:33, ThePhoenix said:

I just tend to use this, as we had to find a way to execute reg files a few years back for intune only devices.

 

https://reg2ps.azurewebsites.net/

Expand  

Hi

what a cool link , maybe there is even reg to bat

thanks

Yes, you should learn PowerShell. The reg2ps site literally gives you the code to save into a PowerShell file (ps1) and run it. Or even use the code I provided works.

This thread has given you the answer to the question you initially asked.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Posts

    • just in time for it to be replaced with something that makes everyone unhappy! - The Microsoft way
    • Is this written by AI? The article contradicts itself and doesn't even line up with the title.
    • Pale Moon 33.7.2 by Razvan Serea Pale Moon is an Open Source, Goanna-based web browser available for Microsoft Windows, Linux and Android, focusing on efficiency and ease of use. Make sure to get the most out of your browser! Pale Moon offers you a browsing experience in a browser completely built from its own, independently developed source that has been forked off from Firefox/Mozilla code, with carefully selected features and optimizations to improve the browsers speed, resource use, stability and user experience, while offering full customization and a growing collection of extensions and themes to make the browser truly your own. Features: Optimized for modern processors Based on proprietary optimized layout engine (Goanna) Safe: forked from mature Mozilla code and regularly updated Secure: Additional security features and security-aware development Supported by our user community, and fully non-profit Familiar, efficient, fully customizable interface Support for full themes: total freedom over any elements design Support for easily-created lightweight themes (skins) Smooth and speedy page drawing and script processing Increased stability: experience fewer browser crashes Support for many Firefox extensions Support for a growing number of Pale Moon exclusive extensions Extensive and growing support for HTML5 and CSS3 Many customization and configuration options Pale Moon 33.7.2 release notes: Addressed PWN2OWN-2025-1 (out of bounds read or write in promise) DiD Addressed PWN2OWN-2025-2 (out of bounds read or write when using the ExtractLinearSum optimization) DiD Fixed potential unexpected behavior in embedded protobuf code. DiD Fixed an issue with potentially uninitialized contrast values when enhanced device contrast values can not be read from the O.S. DiD Fixed potential sanitization issues with devtools' "Copy as curl" feature. It should be noted that we do not currently offer cross-platform "curl" features, so this is another DiD for this release. Download: Pale Moon (64-bit) | Portable 64-bit | ~40.0 MB (Freeware) Download: Pale Moon (32-bit) | Portable 32-bit Links: Pale Moon Homepage | Add-ons | Themes | Extensions | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Another disappointing rumor: iPhone 17 won't get a ProMotion display by Hamid Ganji With the iPad Pro in 2017, Apple introduced a new type of display technology for its devices, dubbed ProMotion. The ProMotion feature enables a variable refresh rate, ranging from 24Hz to 120Hz, and it has a critical role in enhancing display sharpness and responsiveness. With the iPhone 13 Pro and iPhone 13 Pro Max in 2021, the ProMotion feature landed on iPhones, but it has stuck with the Pro variants since then, leaving the standard and Plus versions with a regular Super Retina display. While customers expected to get a ProMotion display on the vanilla iPhone 17, and even some rumors hinted at this possibility, the latest leaks suggest ProMotion remains with the Pro iPhone variants for another generation. According to Chinese leaker Fixed Focus Digital on Weibo, Apple has decided to keep the ProMotion feature exclusive to iPhone 17 Pro and Pro Max, and the rest of the lineup would launch with a “normal 120hz screen”. This Chinese leaker has conflicting reports about Apple’s future products. For now, we should take this claim with a pinch of salt and wait for more confirmation from the Apple supply chain insiders. In September last year, analyst Ross Young said the entire 17 lineup would get the ProMotion feature and the Always-on display (via 9to5mac). Young is also a credible source for Apple-related news, but too many conflicting rumors around upcoming iPhones make us question every claim. The only thing that seems certain so far is that Apple will increase the screen refresh rate on the iPhone 17 and 17 Air to 120Hz, which is a significant increase from the current 60Hz on the iPhone 16 base and Plus variants. Also, by boosting the iPhone 17 and 17 Air refresh rate to 120Hz, Apple is more likely to retain the ProMotion feature for the Pro models in the lineup to differentiate devices better from a marketing standpoint.
    • The article clearly states multiple times that he will DONATE his wealth. There's no mention of any loan, but haters gonna hate. He doesn't need to do this, you know? He could just give all that money to his kids and call it a day.
  • Recent Achievements

    • Week One Done
      Jim Dugan earned a badge
      Week One Done
    • Week One Done
      Adam Todd earned a badge
      Week One Done
    • Contributor
      Ed B went up a rank
      Contributor
    • One Month Later
      moporcho earned a badge
      One Month Later
    • One Month Later
      Parotel earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      211
    2. 2
      snowy owl
      156
    3. 3
      ATLien_0
      134
    4. 4
      Xenon
      119
    5. 5
      +FloatingFatMan
      113
  • Tell a friend

    Love Neowin? Tell a friend!