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

    • Chrome. Because it just works Chrome. Because it just works  
    • I'm curious as to how Apple will marketing it's (lacking) AI-thingy compared to other players in the market. I'm not pro-AI on OS'es, but having practically nothing looks kinda 'sad' to me also.
    • Anthropic cuts off Windsurf's Claude 3.x access: What it means for users by Paul Hill The popular AI-native coding tool, Windsurf, has announced that Anthropic has cut off first-party capacity to its Claude 3 series of models, including Claude 3.5 Sonnet, 3.7 Sonnet, and 3.7 Sonnet Thinking. Until Windsurf can find some capacity to support the demand for these models, it has had to make some short-term changes. One action Windsurf is taking to ease capacity issues is offering a promo rate for Gemini 2.5 Pro of 0.75x credits instead of the usual 1x. Gemini 2.5 Pro is a strong alternative to Claude models for coding, so it could help ease the capacity burden. Additionally, Windsurf has totally removed direct access to the affected Claude models for Free tier users and those trialing the Pro plan. However, you can add your own Claude API key to continue using the model in Windsurf. Claude Sonnet 4 is also available via your own key. Who it affects, and how As a result of the change, users who rely on the Claude 3 series models within Windsurf may experience slower response times or temporary unavailability. As an alternative, users could use the free SWE-1 models or the heavily discounted promo of GPT-4.1. There are other models available for paying customers, too. Users on the Free plan or enjoying a trial of Pro are the most affected by this change is it completely removes first-party capacity, forcing them to create a key and add it manually in Windsurf. This is a big barrier to entry, but some people might be willing to do this as Claude is widely seen as one of the best AI models for coding. The move could be considered a fairly big blow to Windsurf, which was recently in acquisition talks with OpenAI. Given Claude’s reputation as a strong AI for coding, developers could be less likely to use Windsurf now that it doesn’t come with Claude's set and is ready to go on the Free plan. Why it's happening The change came with less than a week’s notice for Windsurf to adapt to the change. While the press release doesn’t disclose the reasons for Anthropic's decision, there is a strong likelihood that it has something to do with OpenAI’s potential acquisition of the IDE. Anthropic and OpenAI were the original leaders competing in the AI race, and Anthropic won’t want to give OpenAI any help if it can help it. The chagrined Windsurf said that it was concerned about Anthropic’s decision and said the move would harm the entire industry, not just Windsurf. It’s unclear what it means by this, as it didn’t elucidate on this thought. Reactions As mentioned earlier, if you have been using Claude models and now feel abandoned by Anthropic and Windsurf, following the latter’s recommendation to use Gemini Pro 2.5 could be a sensible idea. While first-party capacity has been removed, Windsurf is still actively working with other inference providers to restore capacity and full access to the models. Windsurf, while disappointed with Anthropic's move, said the magic of its IDE doesn’t come from the models themselves. Instead, it’s all about the software’s deep contextual understanding, intentional user experience, and unique features like Previews, Deploys, and Reviews. Despite this setback, it will keep trying to deliver “magic.” Given everything, users will now need to decide whether Gemini 2.5 Pro meets their needs or if they need to hunt for a Claude 3 series API key to restore Claude functionality in Windsurf. If you use Windsurf, do not overlook its own model, SWE-1, as it’s also very capable and free to use. This decision by Anthropic highlights the main issue with relying on third parties to provide AI tools that we increasingly rely upon. For businesses like Windsurf, it means they will diversify the models they offer or, as Windsurf has already done, create their own LLMs that they control. For end users, being able to download a language model and run it offline is increasingly becoming easier and ensures users don’t lose access to their favorite models. Windsurf is not the only AI IDE on the scene, and this move could cause problems for it if other players continue to offer Claude models, at least in the short term, while it searches for more capacity. It will also reduce trust between model creators like Anthropic and the companies that rely on the models.
    • Tesla instructor reportedly said staff leave with a 'negative taste in their mouth' by Hamid Ganji Tesla has been making the headlines over the past few months due to Elon Musk's controversy in the Department of Government Efficiency, aka DOGE. People have been marching to the streets, boycotting Tesla, and even setting their already-bought Tesla cars on fire. Tesla temporarily shut down its factory in Austin for the week of Memorial Day, and employees could either take paid time off or attend a series of training sessions. Business Insider now claims to have obtained a recording of the sessions that reveals some interesting details about the Tesla culture and how its employees feel about the company. The Tesla instructor reportedly asked employees to respond if they ever felt "I can't work under these conditions" and were uneasy about the company's constant change. "I know I have," the instructor said. "A lot of people leave this company, and they have kind of a negative taste in their mouth," the Tesla instructor added. "They think: 'Man, it was terrible. It was bad. I got burnt out. I feel like I didn't get anything done, nobody listened to me.'" Hundreds of Tesla employees allegedly attended the meetings, where they were asked to take more responsibility for improving the company's culture. "Leadership has kind of another level of responsibility for trying to guide and direct that culture," the instructor told Tesla staff. "But at the end of the day, it's us as the people on the ground that are the reflection of the culture." Tesla's factory in Austin produces Cybertruck and Model Y. The staff said shutting down the factory for the sake of Memorial Day has been unusual for the company. Elon Musk recently announced that he would leave his position at the White House and added that he'll remain Tesla CEO for another five years. In the meantime, the latest data shows Tesla sales in Europe have dropped 49 percent, and the company's profit in Q1 2025 declined by 71 percent.
  • Recent Achievements

    • Week One Done
      mywakehealth earned a badge
      Week One Done
    • Dedicated
      jbatch earned a badge
      Dedicated
    • Week One Done
      Leonard grant earned a badge
      Week One Done
    • One Month Later
      portacnb1 earned a badge
      One Month Later
    • Week One Done
      portacnb1 earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      284
    2. 2
      snowy owl
      158
    3. 3
      +FloatingFatMan
      148
    4. 4
      ATLien_0
      141
    5. 5
      Xenon
      130
  • Tell a friend

    Love Neowin? Tell a friend!