How can I create a new .reg file from the CLI
up vote
0
down vote
favorite
I'd like to create a new .reg file and add it to the registry, as suggested in this article.
REGEDIT4
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionIniFileMappingAutorun.inf]
@="@SYS:DoesNotExist"
It's pretty simple. But I want to script it. I thought I could just use REG ADD, but I'm not sure how to incorporate the @="@SYS:DoesNotExist" part at the end.
windows-10 command-line windows-registry cmd.exe regedit
add a comment |
up vote
0
down vote
favorite
I'd like to create a new .reg file and add it to the registry, as suggested in this article.
REGEDIT4
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionIniFileMappingAutorun.inf]
@="@SYS:DoesNotExist"
It's pretty simple. But I want to script it. I thought I could just use REG ADD, but I'm not sure how to incorporate the @="@SYS:DoesNotExist" part at the end.
windows-10 command-line windows-registry cmd.exe regedit
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'd like to create a new .reg file and add it to the registry, as suggested in this article.
REGEDIT4
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionIniFileMappingAutorun.inf]
@="@SYS:DoesNotExist"
It's pretty simple. But I want to script it. I thought I could just use REG ADD, but I'm not sure how to incorporate the @="@SYS:DoesNotExist" part at the end.
windows-10 command-line windows-registry cmd.exe regedit
I'd like to create a new .reg file and add it to the registry, as suggested in this article.
REGEDIT4
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionIniFileMappingAutorun.inf]
@="@SYS:DoesNotExist"
It's pretty simple. But I want to script it. I thought I could just use REG ADD, but I'm not sure how to incorporate the @="@SYS:DoesNotExist" part at the end.
windows-10 command-line windows-registry cmd.exe regedit
windows-10 command-line windows-registry cmd.exe regedit
edited Nov 29 at 12:57
asked Nov 29 at 12:07
tjt263
1,28921233
1,28921233
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
Create your batch file - e.g. fix.bat - with the following content:
echo REGEDIT4 > fix.reg
echo [HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionIniFileMappingAutorun.inf] >> fix.reg
echo @="@SYS:DoesNotExist" >> fix.reg
Run the batch and it'll create your file with the desired content. You can manually merge the .reg file or you could go one step further and use the batch file to merge the fix.reg file created with the script into Windows Registry:
echo REGEDIT4 > fix.reg
echo [HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionIniFileMappingAutorun.inf] >> fix.reg
echo @="@SYS:DoesNotExist" >> fix.reg
regedit.exe /S fix.reg
I appreciate it, but yuck. Is that necessary? Can't I justREG ADDit, or something like that?
– tjt263
Nov 29 at 14:29
@tjt263 This answer provides a solution based on the way your question is worded. That is, it creates a.regfile and imports that file.
– Worthwelle
Nov 29 at 16:31
what else ya got
– tjt263
Nov 29 at 17:19
I think LotPings' answer will give you the all-in-one script you seek :)
– Kinnectus
Nov 29 at 17:37
add a comment |
up vote
1
down vote
If you once import that key and look it up with REG QUERY,
you'll see that the first @ refers to the default key of type REG_SZ with content @SYS:DoesNotExist.
So to create the key directly with REG ADD use the following batch which as admin rights are required automatically elevates itself (with UAC dropping in):
:: Q:Test20181129SU_1379397.cmd
@echo off & setlocal EnableExtensions DisableDelayedExpansion
:: if not already running as admin, elevate and run batch again
net file 1>nul 2>&1 || (
powershell -ExecutionPolicy unrestricted -Command ^
"Start-Process -Verb RunAs -FilePath '%comspec%' -ArgumentList '/c %~f0 %*'"
goto :eof
)
:: Put code here that needs elevation
@Echo off
Set "Key=HKLMSOFTWAREMicrosoftWindows NTCurrentVersionIniFileMappingAutorun.inf"
Set "Dat=@SYS:DoesNotExist"
REG ADD "%Key%" /ve /t REG_SZ /d "%Dat%" /f
TIMEOUT /T 10
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1379397%2fhow-can-i-create-a-new-reg-file-from-the-cli%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Create your batch file - e.g. fix.bat - with the following content:
echo REGEDIT4 > fix.reg
echo [HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionIniFileMappingAutorun.inf] >> fix.reg
echo @="@SYS:DoesNotExist" >> fix.reg
Run the batch and it'll create your file with the desired content. You can manually merge the .reg file or you could go one step further and use the batch file to merge the fix.reg file created with the script into Windows Registry:
echo REGEDIT4 > fix.reg
echo [HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionIniFileMappingAutorun.inf] >> fix.reg
echo @="@SYS:DoesNotExist" >> fix.reg
regedit.exe /S fix.reg
I appreciate it, but yuck. Is that necessary? Can't I justREG ADDit, or something like that?
– tjt263
Nov 29 at 14:29
@tjt263 This answer provides a solution based on the way your question is worded. That is, it creates a.regfile and imports that file.
– Worthwelle
Nov 29 at 16:31
what else ya got
– tjt263
Nov 29 at 17:19
I think LotPings' answer will give you the all-in-one script you seek :)
– Kinnectus
Nov 29 at 17:37
add a comment |
up vote
1
down vote
Create your batch file - e.g. fix.bat - with the following content:
echo REGEDIT4 > fix.reg
echo [HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionIniFileMappingAutorun.inf] >> fix.reg
echo @="@SYS:DoesNotExist" >> fix.reg
Run the batch and it'll create your file with the desired content. You can manually merge the .reg file or you could go one step further and use the batch file to merge the fix.reg file created with the script into Windows Registry:
echo REGEDIT4 > fix.reg
echo [HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionIniFileMappingAutorun.inf] >> fix.reg
echo @="@SYS:DoesNotExist" >> fix.reg
regedit.exe /S fix.reg
I appreciate it, but yuck. Is that necessary? Can't I justREG ADDit, or something like that?
– tjt263
Nov 29 at 14:29
@tjt263 This answer provides a solution based on the way your question is worded. That is, it creates a.regfile and imports that file.
– Worthwelle
Nov 29 at 16:31
what else ya got
– tjt263
Nov 29 at 17:19
I think LotPings' answer will give you the all-in-one script you seek :)
– Kinnectus
Nov 29 at 17:37
add a comment |
up vote
1
down vote
up vote
1
down vote
Create your batch file - e.g. fix.bat - with the following content:
echo REGEDIT4 > fix.reg
echo [HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionIniFileMappingAutorun.inf] >> fix.reg
echo @="@SYS:DoesNotExist" >> fix.reg
Run the batch and it'll create your file with the desired content. You can manually merge the .reg file or you could go one step further and use the batch file to merge the fix.reg file created with the script into Windows Registry:
echo REGEDIT4 > fix.reg
echo [HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionIniFileMappingAutorun.inf] >> fix.reg
echo @="@SYS:DoesNotExist" >> fix.reg
regedit.exe /S fix.reg
Create your batch file - e.g. fix.bat - with the following content:
echo REGEDIT4 > fix.reg
echo [HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionIniFileMappingAutorun.inf] >> fix.reg
echo @="@SYS:DoesNotExist" >> fix.reg
Run the batch and it'll create your file with the desired content. You can manually merge the .reg file or you could go one step further and use the batch file to merge the fix.reg file created with the script into Windows Registry:
echo REGEDIT4 > fix.reg
echo [HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionIniFileMappingAutorun.inf] >> fix.reg
echo @="@SYS:DoesNotExist" >> fix.reg
regedit.exe /S fix.reg
answered Nov 29 at 12:16
Kinnectus
8,82921730
8,82921730
I appreciate it, but yuck. Is that necessary? Can't I justREG ADDit, or something like that?
– tjt263
Nov 29 at 14:29
@tjt263 This answer provides a solution based on the way your question is worded. That is, it creates a.regfile and imports that file.
– Worthwelle
Nov 29 at 16:31
what else ya got
– tjt263
Nov 29 at 17:19
I think LotPings' answer will give you the all-in-one script you seek :)
– Kinnectus
Nov 29 at 17:37
add a comment |
I appreciate it, but yuck. Is that necessary? Can't I justREG ADDit, or something like that?
– tjt263
Nov 29 at 14:29
@tjt263 This answer provides a solution based on the way your question is worded. That is, it creates a.regfile and imports that file.
– Worthwelle
Nov 29 at 16:31
what else ya got
– tjt263
Nov 29 at 17:19
I think LotPings' answer will give you the all-in-one script you seek :)
– Kinnectus
Nov 29 at 17:37
I appreciate it, but yuck. Is that necessary? Can't I just
REG ADD it, or something like that?– tjt263
Nov 29 at 14:29
I appreciate it, but yuck. Is that necessary? Can't I just
REG ADD it, or something like that?– tjt263
Nov 29 at 14:29
@tjt263 This answer provides a solution based on the way your question is worded. That is, it creates a
.reg file and imports that file.– Worthwelle
Nov 29 at 16:31
@tjt263 This answer provides a solution based on the way your question is worded. That is, it creates a
.reg file and imports that file.– Worthwelle
Nov 29 at 16:31
what else ya got
– tjt263
Nov 29 at 17:19
what else ya got
– tjt263
Nov 29 at 17:19
I think LotPings' answer will give you the all-in-one script you seek :)
– Kinnectus
Nov 29 at 17:37
I think LotPings' answer will give you the all-in-one script you seek :)
– Kinnectus
Nov 29 at 17:37
add a comment |
up vote
1
down vote
If you once import that key and look it up with REG QUERY,
you'll see that the first @ refers to the default key of type REG_SZ with content @SYS:DoesNotExist.
So to create the key directly with REG ADD use the following batch which as admin rights are required automatically elevates itself (with UAC dropping in):
:: Q:Test20181129SU_1379397.cmd
@echo off & setlocal EnableExtensions DisableDelayedExpansion
:: if not already running as admin, elevate and run batch again
net file 1>nul 2>&1 || (
powershell -ExecutionPolicy unrestricted -Command ^
"Start-Process -Verb RunAs -FilePath '%comspec%' -ArgumentList '/c %~f0 %*'"
goto :eof
)
:: Put code here that needs elevation
@Echo off
Set "Key=HKLMSOFTWAREMicrosoftWindows NTCurrentVersionIniFileMappingAutorun.inf"
Set "Dat=@SYS:DoesNotExist"
REG ADD "%Key%" /ve /t REG_SZ /d "%Dat%" /f
TIMEOUT /T 10
add a comment |
up vote
1
down vote
If you once import that key and look it up with REG QUERY,
you'll see that the first @ refers to the default key of type REG_SZ with content @SYS:DoesNotExist.
So to create the key directly with REG ADD use the following batch which as admin rights are required automatically elevates itself (with UAC dropping in):
:: Q:Test20181129SU_1379397.cmd
@echo off & setlocal EnableExtensions DisableDelayedExpansion
:: if not already running as admin, elevate and run batch again
net file 1>nul 2>&1 || (
powershell -ExecutionPolicy unrestricted -Command ^
"Start-Process -Verb RunAs -FilePath '%comspec%' -ArgumentList '/c %~f0 %*'"
goto :eof
)
:: Put code here that needs elevation
@Echo off
Set "Key=HKLMSOFTWAREMicrosoftWindows NTCurrentVersionIniFileMappingAutorun.inf"
Set "Dat=@SYS:DoesNotExist"
REG ADD "%Key%" /ve /t REG_SZ /d "%Dat%" /f
TIMEOUT /T 10
add a comment |
up vote
1
down vote
up vote
1
down vote
If you once import that key and look it up with REG QUERY,
you'll see that the first @ refers to the default key of type REG_SZ with content @SYS:DoesNotExist.
So to create the key directly with REG ADD use the following batch which as admin rights are required automatically elevates itself (with UAC dropping in):
:: Q:Test20181129SU_1379397.cmd
@echo off & setlocal EnableExtensions DisableDelayedExpansion
:: if not already running as admin, elevate and run batch again
net file 1>nul 2>&1 || (
powershell -ExecutionPolicy unrestricted -Command ^
"Start-Process -Verb RunAs -FilePath '%comspec%' -ArgumentList '/c %~f0 %*'"
goto :eof
)
:: Put code here that needs elevation
@Echo off
Set "Key=HKLMSOFTWAREMicrosoftWindows NTCurrentVersionIniFileMappingAutorun.inf"
Set "Dat=@SYS:DoesNotExist"
REG ADD "%Key%" /ve /t REG_SZ /d "%Dat%" /f
TIMEOUT /T 10
If you once import that key and look it up with REG QUERY,
you'll see that the first @ refers to the default key of type REG_SZ with content @SYS:DoesNotExist.
So to create the key directly with REG ADD use the following batch which as admin rights are required automatically elevates itself (with UAC dropping in):
:: Q:Test20181129SU_1379397.cmd
@echo off & setlocal EnableExtensions DisableDelayedExpansion
:: if not already running as admin, elevate and run batch again
net file 1>nul 2>&1 || (
powershell -ExecutionPolicy unrestricted -Command ^
"Start-Process -Verb RunAs -FilePath '%comspec%' -ArgumentList '/c %~f0 %*'"
goto :eof
)
:: Put code here that needs elevation
@Echo off
Set "Key=HKLMSOFTWAREMicrosoftWindows NTCurrentVersionIniFileMappingAutorun.inf"
Set "Dat=@SYS:DoesNotExist"
REG ADD "%Key%" /ve /t REG_SZ /d "%Dat%" /f
TIMEOUT /T 10
answered Nov 29 at 14:29
LotPings
4,4081720
4,4081720
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1379397%2fhow-can-i-create-a-new-reg-file-from-the-cli%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown