Updating registry via REG files

  • Thread starter Thread starter Gordon
  • Start date Start date
G

Gordon

I'm attempting to setup a generic profile file (REG file) that I can
use to simplify my software setup tasks, in this case, AutoCAD 2005.

In an ARG file (an AutoCAD user profile which is nearly identical in
structure to a REG file) that is dumped for a specific user after
AutoCAD is setup for example, you'll see registry KEY entries similar
this one:

[HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R16.1\ACAD-301:409\Profiles\Gordon\Menus]

Now when making a batch file script (*.bat file), I know I can use
%USERNAME% to plugin the current user name for batch file commands.



Can someone more knowledgable than I tell me if this will work:

[HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R16.1\ACAD-301:409\Profiles\%USERNAME%\Menus]


It would sure be cool (and save me a bunch of time) if I could create
one master REG file that could be applied to any given user, without
having to manually modify the REG file for each user, right after I
finish the Acad install, and have all my network pointers and custom
menus in place. This trick could be applied to other software as
well....

How do I get a registry key entry in a REG file, like the one above, to
plugin the user name?


Or, maybe I'm going about this the wrong way.... Comments welcome!

Thanks
Gordon
 
All air code but something like this VBScript may work.

Dim WshShell, user
Set WshShell=WScript.CreateObject("WScript.Shell")

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objComputer in colComputer
user = objComputer.UserName
Next

WshShell.RegWrite "HKCU\Software\Autodesk\" _
& "AutoCAD\R16.1\ACAD-301:409\Profiles\" _
& user & "\Menus", "SomeValue", REG_SZ"

Set WshShell=Nothing

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

:
| I'm attempting to setup a generic profile file (REG file) that I can
| use to simplify my software setup tasks, in this case, AutoCAD 2005.
|
| In an ARG file (an AutoCAD user profile which is nearly identical in
| structure to a REG file) that is dumped for a specific user after
| AutoCAD is setup for example, you'll see registry KEY entries similar
| this one:
|
|
[HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R16.1\ACAD-301:409\Profiles\Gordon\Menus]
|
| Now when making a batch file script (*.bat file), I know I can use
| %USERNAME% to plugin the current user name for batch file commands.
|
|
|
| Can someone more knowledgable than I tell me if this will work:
|
|
[HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R16.1\ACAD-301:409\Profiles\%USERNAME%\Menus]
|
|
| It would sure be cool (and save me a bunch of time) if I could create
| one master REG file that could be applied to any given user, without
| having to manually modify the REG file for each user, right after I
| finish the Acad install, and have all my network pointers and custom
| menus in place. This trick could be applied to other software as
| well....
|
| How do I get a registry key entry in a REG file, like the one above, to
| plugin the user name?
|
|
| Or, maybe I'm going about this the wrong way.... Comments welcome!
|
| Thanks
| Gordon
|
 
Should have been;

Dim WshShell, WshSysEnv, user
Set WshShell = CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("Process")

user = WshSysEnv("username")

WshShell.RegWrite "HKCU\Software\Autodesk\" _
& "AutoCAD\R16.1\ACAD-301:409\Profiles\" _
& user & "\Menus", "SomeValue", REG_SZ"

Set WshShell=Nothing
Set WshSysEnv=Nothing

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect
 
In said:
I'm attempting to setup a generic profile file (REG file) that I
can use to simplify my software setup tasks, in this case,
AutoCAD 2005.

In an ARG file (an AutoCAD user profile which is nearly
identical in structure to a REG file) that is dumped for a
specific user after AutoCAD is setup for example, you'll see
registry KEY entries similar this one:

[HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R16.1\ACAD-301:409\P
rofiles\Gordon\Menus]

Now when making a batch file script (*.bat file), I know I can
use %USERNAME% to plugin the current user name for batch file
commands.

By having a batchfile expand the variable and write it to a .REG
file first. Then merge the reg file.

Can someone more knowledgable than I tell me if this will work:

[HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R16.1\ACAD-301:409\P
rofiles\%USERNAME%\Menus]


It would sure be cool (and save me a bunch of time) if I could
create one master REG file that could be applied to any given
user, without having to manually modify the REG file for each
user, right after I finish the Acad install, and have all my
network pointers and custom menus in place. This trick could be
applied to other software as well....

If you want to distribute a batch file (that creates and merges a
REG file on-the-fly)...
How do I get a registry key entry in a REG file, like the one
above, to plugin the user name?


Or, maybe I'm going about this the wrong way.... Comments
welcome!

Simplified demo:
======== demo.cmd ==========
@echo off
echo/REGEDIT4 >%temp%\demo.reg
echo/ >>%temp%\demo.reg
echo/[HKEY_CURRENT_USER\_TEST_\%USERNAME%] >>%temp%\demo.reg
echo/ >>%temp%\demo.reg

%systemroot%\regedit.exe /s %temp%\demo.reg
DEL /q %temp%\demo.reg
=============================

It may also be possible to pre-expand a variable in batch, then use
reg.exe with the expanded string.

All assume Keys or REG_SZ strings.
 
Back
Top