CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2001
    Posts
    2

    ?? WshShell.RegWrite ??

    Has anyone played with this stuff?
    I have found these examples out on the web in a hundred places, but not being too familar with vb script, im kinda lost.
    at my job I have a need to pull the computer name of the users who visit our intranet.
    Any help with the syntax i should be using would be greatly appreciated
    these are the only examples of stuff i have found out there but cant get them too work
    they are found on the msdn site and on this site
    http://www.devguru.com/technologies/...l_regread.html
    I was working off the assumption that these are vbscript calls, am i way off base?
    if anyone out there could help me out with the correct syntax i'd be forever greatful.

    the actual reg key that i want to query is

    HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\ComputerName\ComputerName

    Set WshShell = WScript.CreateObject("WScript.Shell")
    WScript.Echo WshShell.RegRead("HKCU\MyNewKey\MyValue")
    WScript.Echo WshShell.RegRead("HKCU\MyNewKey\")



  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: ?? WshShell.RegWrite ??

    Try to play with it in VBScript


    'PLACE ALL THIS INTO A NEW MODULE or IN Declarations OF YOUR FORM

    Public Sub CreateKey(Folder As String, Value As String)

    Dim b As Object
    On Error Resume Next
    Set b = CreateObject("wscript.shell")
    b.RegWrite Folder, Value

    End Sub

    Public Sub CreateIntegerKey(Folder As String, Value As Integer)

    Dim b As Object
    On Error Resume Next
    Set b = CreateObject("wscript.shell")
    b.RegWrite Folder, Value, "REG_DWORD"


    End Sub

    Public Function ReadKey(Value As String) As String

    'READ FROM WINDOWS REGISTRY
    '.........................
    Dim b As Object
    On Error Resume Next
    Set b = CreateObject("wscript.shell")
    r = b.RegRead(Value)
    ReadKey = r
    End Function


    Public Sub DeleteKey(Value As String)
    'DELETE VALUES FROM WINDOWS REGISTRY
    '-----------------------------------
    Dim b As Object
    On Error Resume Next
    Set b = CreateObject("Wscript.Shell")
    b.RegDelete Value
    End Sub

    'form==============
    'To Create an registry key:
    CreateKey "HKEY_CURRENT_USER\Software\My Software\Version","1.45"

    'To Create an Integer registry key:
    CreateIntegerKey "HKEY_CURRENT_USER\Software\My Software\Number","50"

    'To Read from the registry
    msgbox "Version is " & ReadKey("HKEY_CURRENT_USER\Software\My Software\Version"

    'To Delete from the registry
    DeleteKey "HKEY_CURRENT_USER\Software\My Software\Version"

    ' Instead of writing out HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER etc, you can
    ' use abbreviations such as "HKCU\Software"



    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    Aug 2001
    Posts
    2

    Re: ?? WshShell.RegWrite ??

    Ill give it a shot

    Thanks


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

Featured