No announcement yet.

Script for Edit reg value

  • Filter
  • Time
  • Show
Clear All
new posts

  • Script for Edit reg value

    Could some help me with a script to edit a reg value. I would like to write a script to edit the following hkcu\software\microsoft\windows\currentversion\exp lorer\user shell folders\favorites. I would like to change this value from %userprofile%\favorites to \\servername\home\%username%\favorites

  • #2
    Re: Script for Edit reg value

    Here is Microsoft's example for VBS:

    ' Windows Script Host Sample Script
    ' ------------------------------------------------------------------------
    ' Copyright (C) 1996-1997 Microsoft Corporation
    ' You have a royalty-free right to use, modify, reproduce and distribute
    ' the Sample Application Files (and/or any modified version) in any way
    ' you find useful, provided that you agree that Microsoft has no warranty,
    ' obligations or liability for any Sample Application Files.
    ' ------------------------------------------------------------------------
    ' This sample demonstrates how to write/delete entries in the registry.

    L_Welcome_MsgBox_Message_Text = "This script demonstrates how to create and delete registry keys."
    L_Welcome_MsgBox_Title_Text = "Windows Scripting Host Sample"
    Call Welcome()

    ' ************************************************** ******************************
    ' *
    ' * Registry related methods.
    ' *

    Dim WSHShell
    Set WSHShell = WScript.CreateObject("WScript.Shell")

    WSHShell.Popup "Create key HKCU\MyRegKey with value 'Top level key'"
    WSHShell.RegWrite "HKCU\MyRegKey\", "Top level key"

    WSHShell.Popup "Create key HKCU\MyRegKey\Entry with value 'Second level key'"
    WSHShell.RegWrite "HKCU\MyRegKey\Entry\", "Second level key"

    WSHShell.Popup "Set value HKCU\MyRegKey\Value to REG_SZ 1"
    WSHShell.RegWrite "HKCU\MyRegKey\Value", 1

    WSHShell.Popup "Set value HKCU\MyRegKey\Entry to REG_DWORD 2"
    WSHShell.RegWrite "HKCU\MyRegKey\Entry", 2, "REG_DWORD"

    WSHShell.Popup "Set value HKCU\MyRegKey\Entry\Value1 to REG_BINARY 3"
    WSHShell.RegWrite "HKCU\MyRegKey\Entry\Value1", 3, "REG_BINARY"

    WSHShell.Popup "Delete value HKCU\MyRegKey\Entry\Value1"
    WSHShell.RegDelete "HKCU\MyRegKey\Entry\Value1"

    WSHShell.Popup "Delete key HKCU\MyRegKey\Entry"
    WSHShell.RegDelete "HKCU\MyRegKey\Entry\"

    WSHShell.Popup "Delete key HKCU\MyRegKey"
    WSHShell.RegDelete "HKCU\MyRegKey\"

    ' ************************************************** ******************************
    ' *
    ' * Welcome
    ' *
    Sub Welcome()
    Dim intDoIt

    intDoIt = MsgBox(L_Welcome_MsgBox_Message_Text, _
    vbOKCancel + vbInformation, _
    L_Welcome_MsgBox_Title_Text )
    If intDoIt = vbCancel Then
    End If
    End Sub
    If you feel uncomfortable editing this script to suit your needs, I posted a CMD / BAT alternative on your previous thread.

    More info on WSHShell.RegWrite can be had here:

    Or do a search on Google.


    ** Remember to give credit where credit is due and leave reputation points sigpic where appropriate **

    2006-2099 R Valstar. This post is offered "as is" for discussion purposes only with no express or implied warranty of any kind including, but not limited to, correctness or fitness for use. Nothing herein shall be construed as advice. Attempting any activity based on information in this post is done at your own risk.