Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Renaming Registry Key During User Logon

Status
Not open for further replies.

cainecabe

MIS
Aug 5, 2004
45
0
0
US
I am trying to rename a registry keyu in the hkcu hive. Offline files creates a reg key for its cached drives (ex.,
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\NetCache\shares\//nyhomes01/us00002$
(Note: the //nyhomes01/us00002$ is what i want to change, or rename, to //nyhomes01/nm00002$)

So, i want to add this small vb script to run at the users logon (500+ users with different usernames). So i will beed to pull the username environmental variable to catch their username and then drop it into the script, hence the renaming of the registry key.

i have looked all over this site for soehitng similar and i havent found anything.
Any help would be greatly appreciated on this one.

thanks,

Thanks,
 
those links really don't help me at all. i am looking for an example of a vbs script that changes the name of subkey (shown above).

thanks

Thanks,
 
Distribute a WSH File (.vbs) to Create the Entries
Closely related to the reg file solution is the WSH file method.

Windows Scripting Host files use VBS code to access the exposed methods and properties of COM objects, such as the Windows Scripting Shell object. This object model includes methods to read from and write to the Windows Registry. Using the same Registry information provided above, a VBS file can be created to add the desired Registry Keys.

The advantage of using VBS is that, in addition to being able to distribute the pubs.vbs file to users, the code itself will run in any VB or VBA application such as Microsoft Word, Excel or Access thereby moving the responsibility for executing the code from the user to the application itself. Additionally, since this script is written in VBS, it will execute equally well from an ASP page.

(Copy this text to Notepad and save it as pubs.vbs)
Dim oWshShell
Const cRegKey1 = "HKCU\Software\ODBC\ODBC.INI\Pubs\"
Const cRegKey2 = "HKCU\Software\ODBC\ODBC.INI\ODBC Data Sources\"

Set oWshShell = CreateObject ("WScript.Shell")

oWshShell.RegWrite cRegKey1 & "Driver","C:\\WINNT\\System32\\sqlsrv32.dll"
oWshShell.RegWrite cRegKey1 & "Server","GothemCity"
oWshShell.RegWrite cRegKey1 & "Database","pubs"
oWshShell.RegWrite cRegKey1 & "LastUser","Alfred"

oWshShell.RegWrite cRegKey2 & "Pubs","SQL Server"

set oWshShell = Nothing




 
i really appreciate your assistance but i am very new to this and i dont see any renaming (i can't replace i must rename). So, if i wanted to change one of the HKCU entries, such as;

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\NetCache\shares\//nyhomes01/us00002$

to

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\NetCache\shares\//nyhomes01/nm00002$

How would i go about doing that? Is it strange that the last key has double forward slashes in stead of a single backslash?
I need to make the file a vbs file to conform to the standards here.

thanks very much,

Thanks,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top