Adding Vaule Data to and Existing Entry

  • Thread starter Thread starter Chris Kitzmann
  • Start date Start date
C

Chris Kitzmann

Here is my current *.reg file. I am wondering how I can
get \\\\Bmkc1alsol01\\ESTeam6\\Setup\\Lisp Files added
into this entry without replacing anything else in the
entry. I can get it to add it if I replace the whole
entry but I do not what to write over anything that the
use may have placed in this file. Please help if you can.

[HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R15.0\ACAD-
1:409\Profiles\<<Unnamed Profile>>\General]
"ACAD"="C:\\ACAD2000\\Support;\\\\bmkc1alsol01
\\ACAD2K\\ACAD2000\\support;C:\\ACAD2000
\\fonts;\\\\bmkc1alsol01\\ACAD2K\\ACAD2000
\\Fonts;C:\\ACAD2000\\Help;\\\\bmkc1alsol01
\\ACAD2K\\ACAD2000\\Help;C:\\ACAD2000
\\Express;\\\\Bmkc1alsol01\\acad2k\\ACAD2000
\\express;\\\\bmkc1alsol01
\\ProgramFiles\\Butler\\Acad2k\\Lisp;\\\\bmkc1alsol01
\\ProgramFiles\\Butler\\Acad2k\\Symbols;\\\\bmkc1alsol01
\\ProgramFiles\\Butler\\Smart;\\\\bmkc1alsol01
\\std_drawings;\\\\bmkc1alsol01
\\std_drawings\\Cadlib;\\\\Bmkc1alsol01
\\Process\\ZRegion\\Custom_Details\\Z
Details;\\\\Bmkc1alsol01
\\Process\\ZRegion\\Custom_Details\\Custom
Details;\\\\Bmkc1alsol01\\ESTeam6\\Setup\\Steel.lsp
Files;\\\\Bmkc1alsol01\\ESTeam6\\Setup\\Menu
Files;\\\\Bmkc1alsol01\\Process\\ZRegion\\Research\\Lisp;"
 
Export the desired key, open the *.reg file with notepad.exe, delete all
lines except the key name and value you wish to edit, save the file.

--
Regards,

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


:
| Here is my current *.reg file. I am wondering how I can
| get \\\\Bmkc1alsol01\\ESTeam6\\Setup\\Lisp Files added
| into this entry without replacing anything else in the
| entry. I can get it to add it if I replace the whole
| entry but I do not what to write over anything that the
| use may have placed in this file. Please help if you can.
|
| [HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R15.0\ACAD-
| 1:409\Profiles\<<Unnamed Profile>>\General]
| "ACAD"="C:\\ACAD2000\\Support;\\\\bmkc1alsol01
| \\ACAD2K\\ACAD2000\\support;C:\\ACAD2000
| \\fonts;\\\\bmkc1alsol01\\ACAD2K\\ACAD2000
| \\Fonts;C:\\ACAD2000\\Help;\\\\bmkc1alsol01
| \\ACAD2K\\ACAD2000\\Help;C:\\ACAD2000
| \\Express;\\\\Bmkc1alsol01\\acad2k\\ACAD2000
| \\express;\\\\bmkc1alsol01
| \\ProgramFiles\\Butler\\Acad2k\\Lisp;\\\\bmkc1alsol01
| \\ProgramFiles\\Butler\\Acad2k\\Symbols;\\\\bmkc1alsol01
| \\ProgramFiles\\Butler\\Smart;\\\\bmkc1alsol01
| \\std_drawings;\\\\bmkc1alsol01
| \\std_drawings\\Cadlib;\\\\Bmkc1alsol01
| \\Process\\ZRegion\\Custom_Details\\Z
| Details;\\\\Bmkc1alsol01
| \\Process\\ZRegion\\Custom_Details\\Custom
| Details;\\\\Bmkc1alsol01\\ESTeam6\\Setup\\Steel.lsp
| Files;\\\\Bmkc1alsol01\\ESTeam6\\Setup\\Menu
| Files;\\\\Bmkc1alsol01\\Process\\ZRegion\\Research\\Lisp;"
|
 
Dave,

Thanks for your reply.

That sounds great but what if I wanted to do this in a *.reg file or a batch routine? The reason for this is that I am going to be making this change on over 50 computers. Can this be done?

Chris Kitzmann
 
:
| Dave,
|
| Thanks for your reply.
|
| That sounds great but what if I wanted to do this in a *.reg file or a
batch routine?
* The steps I outlined are for creating a *.reg file.

The reason for this is that I am going to be making this change on over 50
computers. Can this be done?
* Yes it can be done. Might be easier to use RegWrite method of VBScript.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsMthRegWrite.asp

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect
 
Chris said:
Here is my current *.reg file. I am wondering how I can
get \\\\Bmkc1alsol01\\ESTeam6\\Setup\\Lisp Files added
into this entry without replacing anything else in the
entry. I can get it to add it if I replace the whole
entry but I do not what to write over anything that the
use may have placed in this file. Please help if you can.

[HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R15.0\ACAD-
1:409\Profiles\<<Unnamed Profile>>\General]
"ACAD"="C:\\ACAD2000\\Support;\\\\bmkc1alsol01
(snip)
Hi

Below is a vbscript that does the job. It adds the path only if it
doesn't exist from before (and will also check to see if a ; is
needed before the new path).

As your new path entry contains a space, I have also added quotes
around it when writing it to registry (see comments in the code
for a regwrite version that doesn't add quotes if that isn't
possible to use).


WSH 5.6 documentation (local help file) can be downloaded from here if you
haven't got it already:
http://msdn.microsoft.com/downloads/list/webdev.asp


'--------------------8<----------------------
Set oShell = CreateObject("WScript.Shell")

sRegValueName = "HKCU\Software\Autodesk\AutoCAD\R15.0\ACAD-1:409" _
& "\Profiles\<<Unnamed Profile>>\General\Acad"

sNewPath = "\\Bmkc1alsol01\ESTeam6\Setup\Lisp Files"

On Error Resume Next
sRegValueData = "" ' init value
sRegValueData = oShell.RegRead(sRegValueName)
On Error Goto 0

' Check if the value is already in place
If InStr(1, sRegValueData, sNewPath, vbTextCompare) = 0 Then

' check if there is an terminating ; at the end of the original string
If Right(sRegValueData, 1) = ";" Then
sPrefix = "" ' no prefix is necessary
Else
sPrefix = ";" ' prefix is necessary on sNewPath
End If

' add quotes around the new path because it contains space,
' and also add an terminating ;
oShell.RegWrite sRegValueName, _
sRegValueData & sPrefix & """" & sNewPath & """;", "REG_SZ"

' if you can't use quoutes around the path, use this line instead
'oShell.RegWrite sRegValueName, sRegValueData & sPrefix & sNewPath & ";"

End If
'--------------------8<----------------------
 
Thnks for the reply. It looks like I am going to have to some some homework so that I understand everything that is going on in this.

Torgeir Bakken (MVP) said:
Chris said:
Here is my current *.reg file. I am wondering how I can
get \\\\Bmkc1alsol01\\ESTeam6\\Setup\\Lisp Files added
into this entry without replacing anything else in the
entry. I can get it to add it if I replace the whole
entry but I do not what to write over anything that the
use may have placed in this file. Please help if you can.

[HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R15.0\ACAD-
1:409\Profiles\<<Unnamed Profile>>\General]
"ACAD"="C:\\ACAD2000\\Support;\\\\bmkc1alsol01
(snip)
Hi

Below is a vbscript that does the job. It adds the path only if it
doesn't exist from before (and will also check to see if a ; is
needed before the new path).

As your new path entry contains a space, I have also added quotes
around it when writing it to registry (see comments in the code
for a regwrite version that doesn't add quotes if that isn't
possible to use).


WSH 5.6 documentation (local help file) can be downloaded from here if you
haven't got it already:
http://msdn.microsoft.com/downloads/list/webdev.asp


'--------------------8<----------------------
Set oShell = CreateObject("WScript.Shell")

sRegValueName = "HKCU\Software\Autodesk\AutoCAD\R15.0\ACAD-1:409" _
& "\Profiles\<<Unnamed Profile>>\General\Acad"

sNewPath = "\\Bmkc1alsol01\ESTeam6\Setup\Lisp Files"

On Error Resume Next
sRegValueData = "" ' init value
sRegValueData = oShell.RegRead(sRegValueName)
On Error Goto 0

' Check if the value is already in place
If InStr(1, sRegValueData, sNewPath, vbTextCompare) = 0 Then

' check if there is an terminating ; at the end of the original string
If Right(sRegValueData, 1) = ";" Then
sPrefix = "" ' no prefix is necessary
Else
sPrefix = ";" ' prefix is necessary on sNewPath
End If

' add quotes around the new path because it contains space,
' and also add an terminating ;
oShell.RegWrite sRegValueName, _
sRegValueData & sPrefix & """" & sNewPath & """;", "REG_SZ"

' if you can't use quoutes around the path, use this line instead
'oShell.RegWrite sRegValueName, sRegValueData & sPrefix & sNewPath & ";"

End If
'--------------------8<----------------------


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/community/scriptcenter/default.mspx
 
Chris said:
Is there any way to add something in front of and behind the existing string?
Hi

Yes, here is a version that does this, update the variables
sNewPathFront and sNewPathBehind to contain the paths you
want to add.


'--------------------8<----------------------
Set oShell = CreateObject("WScript.Shell")

sRegValueName = "HKCU\Software\Autodesk\AutoCAD\R15.0\ACAD-1:409" _
& "\Profiles\<<Unnamed Profile>>\General\Acad"

sNewPathFront = "\\Bmkc1alsol01\ESTeam6\Setup\MyFiles"
sNewPathBehind = "\\Bmkc1alsol01\ESTeam6\Setup\Lisp Files"

On Error Resume Next
sRegValueData = "" ' init value
sRegValueData = oShell.RegRead(sRegValueName)
On Error Goto 0

If sRegValueData = "" Then
' the Acad value does not exist in registry, so we quit
WScript.Quit
End If

' Check if the value for sNewPathFront is already in place
If InStr(1, sRegValueData, sNewPathFront, vbTextCompare) = 0 Then

' add quotes around the new path because it might contain spaces,
' and also add an terminating ;
oShell.RegWrite sRegValueName, _
"""" & sNewPathFront & """;" & sRegValueData, "REG_SZ"

' if you can't use quoutes around the path, use this line instead
'oShell.RegWrite sRegValueName, _
' sRegValueData & sPrefix & sNewPathFront & ";"

End If

' Check if the value for sNewPathBehind is already in place
If InStr(1, sRegValueData, sNewPathBehind, vbTextCompare) = 0 Then

' Read the data again so the sNewPathBehind handling further down
' operates on an updated string (sNewPathFront is most likely added)
' No point in error handling the RegRead anymore, because now the
' registry value will exist anyway
sRegValueData = oShell.RegRead(sRegValueName)

' check if there is an terminating ; at the end of the original string
If Right(sRegValueData, 1) = ";" Then
sPrefix = "" ' no prefix is necessary
Else
sPrefix = ";" ' prefix is necessary on sNewPathBehind
End If

' add quotes around the new path because it might contain spaces,
' and also add an terminating ;
oShell.RegWrite sRegValueName, _
sRegValueData & sPrefix & """" & sNewPathBehind & """;", "REG_SZ"

' if you can't use quoutes around the path, use this line instead
'oShell.RegWrite sRegValueName, _
' sRegValueData & sPrefix & sNewPathBehind & ";"

End If
'--------------------8<----------------------
 
Back
Top