Results 1 to 8 of 8

Thread: Network registry editor

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2006
    Posts
    70

    Network registry editor

    I use a small vbs program to connect to another computer on our network and disable the smart card force option so we (techs) can log in manually. I didn't write this program but I was wondering if anybody could tell me what the specific calls are doing.

    Code:
    const HKEY_LOCAL_MACHINE = &H80000002
    strComputer = InputBox("Enter the NetBIOS Name or IP address of the computer you wish to disable Smart Card Logon:")
    
    If strComputer = "" Then
    MsgBox "Nothing was entered in the inputbox" & vbCrLf & "Or you pressed the Cancel Button"
    Else:
    Set StdOut = WScript.StdOut
    
    Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ 
    strComputer & "\root\default:StdRegProv")
    
    strKeyPath = "SOFTWARE\Microsoft\windows\currentversion\policies\system"
    strValueName = "ScForceOption"
    dwValue = 0
    oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue
    
    End If
    
    wscript.Echo strComputer & " is NOT forced to use Smart Card Logon!"

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Network registry editor

    Thread moved from CodeBank forum (which is not for asking questions)

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Network registry editor

    looks straightforward, creates a registry object (oreg), defines the key, keypath and new value, then sets the new value

    you should be setting back to the old value after finishing your task
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 2006
    Posts
    70

    Re: Network registry editor

    I got that much. I have never seen this:

    Set StdOut = WScript.StdOut

    Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
    strComputer & "\root\default:StdRegProv")

    What is this doing?

  5. #5
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Network registry editor

    stdout is just an output method of the windows scripting host to log to

    oreg is a created registry objectby wimdowsmanagement (WMI) to the computer in strcomputer
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  6. #6

    Thread Starter
    Lively Member
    Join Date
    May 2006
    Posts
    70

    Resolved Re: Network registry editor

    Cool. thanks.

  7. #7

    Thread Starter
    Lively Member
    Join Date
    May 2006
    Posts
    70

    Re: Network registry editor

    Since I haven't been here too many times, how do I mark this as resolved?

  8. #8
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Network registry editor

    put the green check on the first post, by editing, or use thread tools > mark thread resolved
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

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