Import REG file

Import REG file

JeffPaulsen
Collaborator Collaborator
1,631 Views
4 Replies
Message 1 of 5

Import REG file

JeffPaulsen
Collaborator
Collaborator

How do I import a REG file using VBA? I am pretty much a hack when it comes to programming so please bear with me. I found two scripts online that I modified but neither worked. The VBA project runs with no errors but the registry is not modified. Here are the two scripts that I tried. Does anyone have a script that will work?

 

Private Sub ImportReg()
CreateObject("WScript.Shell").Run "%WinDir%\Regedit.exe /s ""Z:\Autodesk 2020\default scale list.reg"""
End Sub

 

Private Sub ImportReg()
Set ofile = CreateObject("scripting.FileSystemObject")
Set oshell = CreateObject("wscript.shell")
           
    sRegFile = "Z:\Autodesk 2020\default scale list.reg"
       
        If ofile.FileExists(sRegFile) Then
        iReturn = oshell.Run("regedit.exe /s" & sRegFile)

Set ofile = Nothing
Set oshell = Nothing
End Sub

 

Jeff Paulsen
Civil 3D 2020.4 | Win 10 Pro N 64-bit
Xeon W-2223 @ 3.60GHz, 32GB Ram | NVidia Quadro P2200
0 Likes
1,632 Views
4 Replies
Replies (4)
Message 2 of 5

Ed__Jobe
Mentor
Mentor

Does the user running the sub have admin rights to the pc? You need to be an admin to update the registry with a reg file, at least for certain areas of the registry. Does the reg file update properly if you double click on it? iow, is it formatted properly to the correct keys?

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 3 of 5

JeffPaulsen
Collaborator
Collaborator

I was able to merge the REG file without administrative privileges and it modified the registry correctly.

Jeff Paulsen
Civil 3D 2020.4 | Win 10 Pro N 64-bit
Xeon W-2223 @ 3.60GHz, 32GB Ram | NVidia Quadro P2200
0 Likes
Message 4 of 5

JeffPaulsen
Collaborator
Collaborator

Is there a way to load this reg file with VBA? As stated, the user has permission to run the REG file.

Jeff Paulsen
Civil 3D 2020.4 | Win 10 Pro N 64-bit
Xeon W-2223 @ 3.60GHz, 32GB Ram | NVidia Quadro P2200
0 Likes
Message 5 of 5

Ed__Jobe
Mentor
Mentor

By the title of your reg file, it looks like you are trying to set up a custom list to use as a default for another sub that will import the list to a dwg? Correct? You might try using the SaveSetting method and retrieving with GetSetting. It uses a special section of HKCU. You give your section an appname and store your settings there.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes