Adapting .REG Files.

Page 8 of 13 FirstFirst ... 678910 ... LastLast
  1. Matthew Wai's Avatar
    Posts : 5,072
    Windows 10 Home 20H2
       #71

    Reg import "E:\Testing\Winver.reg" &:: It will return an error if an error arises.
    Regedit /s "E:\Testing\Winver.reg" &:: It will return nothing even if an error arises.
      My Computer

  2. Matthew Wai's Avatar
    Posts : 5,072
    Windows 10 Home 20H2
       #72

    Another test via a CMD script.
    Code:
    @echo off
    (Net session >nul 2>&1)||(PowerShell start -verb runas '%~0' &exit /b)
    For %%I In ("E:\Testing\*.reg") Do (Echo.
    Echo --^>"%%I" is going to be imported.
    Reg import "%%I" && CD.||pause)
    The output is shown below.
    Code:
    -->"E:\Testing\Metered Connections.reg" is going to be imported.
    ERROR: Error accessing the registry.
    Press any key to continue . . .
    
    -->"E:\Testing\System Properties.reg" is going to be imported.
    The operation completed successfully.
    
    -->"E:\Testing\Testing.reg" is going to be imported.
    ERROR: The specified file is not a registry file. You can import only registry files.
    Press any key to continue . . .
    The first error denotes "Access denied" due to insufficient privileges.
    The second was due to the absence of Windows Registry Editor Version 5.00
    The process will be paused only if an error has arisen.
      My Computer

  3. Matthew Wai's Avatar
    Posts : 5,072
    Windows 10 Home 20H2
       #73

    I just found that && CD. is unneeded and can be omitted from the last line of the script.
      My Computer

  4. Paul Black's Avatar
    Posts : 12,191
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
    Thread Starter
       #74

    That works brilliantly @Matthew Wai, thank you.

    I setup a Test.reg [without the Windows Registry Editor Version 5.00] and it gave me the expected ERROR.

    This is the finished code . . .
    Code:
    @echo off
    Set Folder=C:\Implementation
    Set Count = 0
    (Net session >nul 2>&1)||(PowerShell start -verb runas '%~0' &exit /b)
    For %%j In ("%Folder%\*.reg") Do Set /A Count += 1
    echo Processing [ Merging ] REG files . . . & echo.
    For %%i In ("%Folder%\*.reg") Do (echo.
    echo "%%i".
    Reg import "%%i" ||Pause)
    echo. & echo Processed [ Merged ] %Count% REG files successfully! & echo. & Pause
    I will have ago at setting up the same sort of thing for .bat [I mean .cmd] and .ps1 as I attempted to do in a previous post!

    Thanks again!
      My Computer

  5. Matthew Wai's Avatar
    Posts : 5,072
    Windows 10 Home 20H2
       #75

    Paul Black said:
    I setup a Test.reg [without the Windows Registry Editor Version 5.00] and it gave me the expected ERROR.
    Try the following one, which will give you another error: access denied.

    Code:
    Windows Registry Editor Version 5.00
    [HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\DefaultMediaCost]
    "Ethernet"=dword:00000002
    PowerRun, third-party software, allows you access to modify the "dword" of "Ethernet".
      My Computer

  6. Matthew Wai's Avatar
    Posts : 5,072
    Windows 10 Home 20H2
       #76

    Paul Black said:
    Code:
    echo. & echo Processed [ Merged ] %Count% REG files successfully! & echo. & Pause
    The above output the following when two of the three REG files could not be merged.
    Code:
    Processed [ Merged ] 3 REG files successfully!
    Actually, only one file was merged successfully.
      My Computer

  7. Paul Black's Avatar
    Posts : 12,191
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
    Thread Starter
       #77

    Thank so much Matthew Wai for all your expertise, it is appreciated.

    I am pretty confident that ALL the .reg files will be OK anyway as they come from TenForums!

    I have over a 100 .reg files now so the program will be extremely time saving and useful.

    I really need one each for .bat and .ps1 files as I also have quite a lot of them now. Did you see my attempt at creating them in a previous post?

    Thanks in advance!
      My Computer

  8. Matthew Wai's Avatar
    Posts : 5,072
    Windows 10 Home 20H2
       #78

    Paul Black said:
    Did you see my attempt at creating them in a previous post?
    Do you mean the one in post #66? I have not run it. Have you? If so, have you found any errors?

    Paul Black said:
    Thank so much Matthew Wai for all your expertise, it is appreciated.
    Shamefully, I have been banned from asking a question on stackoverflow.com because I asked too many stupid questions, which received dozens of downvotes.
      My Computer

  9. Paul Black's Avatar
    Posts : 12,191
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
    Thread Starter
       #79

    Hello @Matthew Wai,

    Matthew Wai said:
    Do you mean the one in post #66? I have not run it. Have you? If so, have you found any errors?
    Yes, I haven't as yet!

    Matthew Wai said:
    Shamefully, I have been banned from asking a question on stackoverflow.com because I asked too many stupid questions, which received dozens of downvotes.
    Their loss Matthew!
      My Computer

  10. Matthew Wai's Avatar
    Posts : 5,072
    Windows 10 Home 20H2
       #80

    I just ran your script in post #66 and got the following:
    Code:
    Processing BAT file: "E:\Testing\Testing batch.bat".
    '/q' is not recognized as an internal or external command,
    operable program or batch file.
    Operations completed.
    Press any key to continue . . .
      My Computer


 
Page 8 of 13 FirstFirst ... 678910 ... LastLast

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 19:42.
Find Us




Windows 10 Forums