2 Attachment(s)
scipt to apply registry key to hkcu
:)
Hi All,
I am new to vb scripting and was hoping someone can help me out. I have a vbscript that I have included below that I am using to make an application terminal server/ citrix capable. What I am trying to do is inside the vbscript call a registry file that will apply to each new users HKCU path noted in the reg file. The challenge is that i have a reg file, but can't seem to figure out what variable I need to put inside the reg file to change the username to be like a %userprofile% or %username% so that when the registry gets imported into each users profle its shows their username and not %userprofile% or something similar. The application wont fire off if that part in the registry doesn't have a valid path. I have in the regfile now %username% and its not working.
I have attached vbscript application code and the small reg code. I am hoping that there is just some other variable that I can place in the .reg file that will make it change itself to the username logging in. I am also curious if the statement in the vbscript is correct to call the registry file. If anyone knows of an easier to gets these reg values imported I would be ecstatic.
Thank you Gurus
Re: scipt to apply registry key to hkcu
forgot to mention that the values in the registry file alread exist when the user logs in. It just shows another users name so my thought was to export all the keys from a user that is working and just import them when a new users logs into to show their username and not the other username.
Re: scipt to apply registry key to hkcu
Quote:
Originally Posted by sanchito75
forgot to mention that the values in the registry file alread exist when the user logs in. It just shows another users name so my thought was to export all the keys from a user that is working and just import them when a new users logs into to show their username and not the other username.
Why not do it all in the VBScript file ?
Something like this should work great. I have only included one line from the reg file but you should get the idea.
Code:
Call oShell.RegWrite("HKEY_CURRENT_USER\Software\Attachmate\Accessory Manager\WorkstationUser\Preferences\DirIC32CFG", "C:\Documents and Settings\" & CtxUser & "\My Documents\Attachmate\INFOCNEE", "REG_SZ")
All the registry entries seem to be strings so just copy this line and change the entries to match you reg file.
Just a note to, you can not import a registry file (regedit.exe /s regfile.reg) on Windows Vista as a standard user with UAC turned on BUT you can use a VBScript.....Thanks Microsoft
Hope this helps
Rodney
Re: scipt to apply registry key to hkcu
aweseome....So when I change the code to below
Call oShell.RegWrite("HKEY_CURRENT_USER\Software\Attachmate\Accessory Manager\WorkstationUser\Preferences\DirIC32CFG", "C:\Documents and Settings\" & CtxUser & "\My Documents\Attachmate\INFOCNEE", "REG_SZ")
Will every user get a path that shows their username in the registry path for the application as opposed to showing someone elses profile path?
:wave:
Re: scipt to apply registry key to hkcu
Quote:
Originally Posted by sanchito75
Will every user get a path that shows their username in the registry path for the application as opposed to showing someone elses profile path?
Welcome to the forums sanchito75! :wave: The HKEY_CURRENT_USER registry hive is completely unique to every user who logs onto a Windows computer, yes. Incidentally, this actual hive is stored within one or 2 files located in each user's Documents and Settings folder (Windows profile) and by default, can't be accessed or read by most normal users. :)