Results 1 to 5 of 5

Thread: scipt to apply registry key to hkcu

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2008
    Posts
    3

    Talking 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
    Attached Files Attached Files

  2. #2

    Thread Starter
    New Member
    Join Date
    Jul 2008
    Posts
    3

    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.

  3. #3
    New Member Rodent2008's Avatar
    Join Date
    Jul 2008
    Posts
    10

    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
    Last edited by Rodent2008; Jul 28th, 2008 at 07:30 AM.

  4. #4

    Thread Starter
    New Member
    Join Date
    Jul 2008
    Posts
    3

    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?

  5. #5
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    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! 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.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width