Announcement

Collapse
No announcement yet.

Disable/Enable CYBERsitter 2003

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Disable/Enable CYBERsitter 2003

    EDIT = This is Visual Basics if you hadn't noticed

    Im working with the methods "RegWrite" and "RegDelete".
    What I have done is exported the .reg file which I need to write "Net98".
    I need a script along these lines

    Code:
    dim i
    I=Inputbox("Would you like to delete or write Net98? (type write or delete")
    if i=delete then
    This is where I kind of need help.
    The registry directory that I would need to delete is;
    HKLM\SYSTEM\CurrentControlSet\Control\SecurityProv iders\Net98
    and the .reg file I exported Net98 to is;
    C:\Cyb.reg

    Edit:It's not that you have saved the key, it's that you know the keyname, valuename, type and value

    I need an "If delete then *delete the certain registry key*"
    and I need an "Elseif write then *write the .reg file to registry*"
    and possibly a msgbox of "You have deleted/written Net98/Cyb.reg

    Any suggestions ?

    Thanks
    Last edited by retallick; 17th February 2007, 22:11.

  • #2
    Re: Disable/Enable CYBERsitter 2003

    If you want to import complex registry entries, then use a reg-file (what you want to do). And import this file with the dos command "regedit.exe". In vbscript you can use "shell.Run" to execute dos-commands.

    For deleting a complete registrykey by using a vbscript, you have to write a subroutine for that. The subroutine first enummerates and deletes all subkeys of the key you want to delete. Then finaly it can delete the key it self.

    Code:
    sRegFile = "C:\Cyb.reg"
    strHKLMpath = "SYSTEM\CurrentControlSet\Control\SecurityProviders\Net98"
    
    
    Set objShell = WScript.CreateObject("WScript.Shell")
    
    Do While X = 0
      strInput = InputBox (vbCRLF & _
            "Would you like to delete or import the '" & _
             Right(strHKLMpath,Len(strHKLMpath)-InStrRev(strHKLMpath,"\")) & _
            "-key'?" & vbCRLF & vbCRLF & "type:" & vbCRLF & _
            "           Import  -or-  Delete","type your answer",strInput)
      If strInput = Cancel  Then  WScript.Quit 'Cancel was pressed
        Select case LCase(strInput)
               case "import"   Exit Do
               case "delete"  Exit Do
               case else BtnCode = objShell.Popup("You must enter a" & _
                    " correct answer." & vbCRLF & "  (type: import" & _
                    " or delete )", 3, "try again", 1)
                     Select Case BtnCode
                            case 1   'OK, ask Input again
                            case 2   wscript.quit 0 'Cancel, not asking again
                            case -1  'timed out, ask Input again
                     End Select
        End Select
    Loop '(end of INPUTcheck for one-of-the-only-2-options)
    
    
    'do your thing:
    
    On Error Resume Next
    Const HKEY_LOCAL_MACHINE = &H80000002
    strComputer = "."
    
      If strInput = Lcase("import") then
         strChosen = Ucase(strInput) & " ---> " & _
                           Right(sRegFile,Len(sRegFile)-InStrRev(sRegFile,"\"))
         objShell.Run "regedit.exe /s " & Chr(34) & sRegFile & Chr(34), 0, True
         
      Else 'delete the key and subkeys
         strChosen = Ucase(strInput) & " ---> " & _
                  Right(strHKLMpath,Len(strHKLMpath)-InStrRev(strHKLMpath,"\"))
         DeleteRegKey HKEY_LOCAL_MACHINE, strHKLMpath 
    
      End IF
    
    
    wscript.Echo "       You have chosen to  " & strChosen & vbCRLF & _
                         vbCRLF & _
    "(You may have to restart your computer to make the changes effective)"
    
    
    wscript.quit 0  'End of script!!!
    
    
    '----functions and Routines----
    
    Sub DeleteRegKey(HKEY_LOCAL_MACHINE, strHKLMpath)
        Set objRegistry=GetObject("winmgmts:\\" & _ 
                        strComputer & "\root\default:StdRegProv")
     'first check... and delete subkeys if they exists
        objRegistry.EnumKey HKEY_LOCAL_MACHINE, strHKLMpath, arrSubkeys 
        If IsArray(arrSubkeys) Then 
            For Each strSubkey In arrSubkeys 
                DeleteRegKey HKEY_LOCAL_MACHINE, strHKLMpath & "\" & strSubkey 
            Next 
        End If
     'no subkeys left, now continue deleting the key it self
        objRegistry.DeleteKey HKEY_LOCAL_MACHINE, strHKLMpath
    End Sub
    \Rem
    Last edited by Rems; 19th February 2007, 22:24. Reason: ADDED: a msgbox of "You have deleted/written Net98/Cyb.reg

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment


    • #3
      Re: Disable/Enable CYBERsitter 2003

      An additional feature is first to check if the registry-key already exists.
      Then put the expected "action" already as default input.

      This is the modified script;
      Code:
      sRegFile = "C:\Cyb.reg"
      strHKLMpath = "SYSTEM\CurrentControlSet\Control\SecurityProviders\Net98"
      
      On Error Resume Next
      
      Const HKEY_LOCAL_MACHINE = &H80000002
       strComputer = "."
       strInput = ""
      Set objRegistry=GetObject("winmgmts:\\" & _ 
                          strComputer & "\root\default:StdRegProv")
      
      If objRegistry.EnumKey(HKEY_LOCAL_MACHINE, strHKLMpath) <> 0 Then
       strInput = "import"
      Else
       strInput = "delete"
      End if
      
      Set objShell = WScript.CreateObject("WScript.Shell")
      
      '- - - begin: INPUTBOX - - - - - -
      Do While X = 0
        strInput = InputBox (vbCRLF & _
              "Would you like to delete or import the '" & _
               Right(strHKLMpath,Len(strHKLMpath)-InStrRev(strHKLMpath,"\")) & _
              "-key'?" & vbCRLF & vbCRLF & "type:" & vbCRLF & _
              "           Import  -or-  Delete", "type your answer", strInput)
        If strInput = Cancel  Then  WScript.Quit 'Cancel was pressed
          Select case LCase(strInput)
                 case "import"   Exit Do
                 case "delete"  Exit Do
                 case else BtnCode = objShell.Popup("You must enter a" & _
                      " correct answer." & vbCRLF & "  (type: import" & _
                      " or delete )", 3, "try again", 1)
                       Select Case BtnCode
                              case 1   'OK, ask Input again
                              case 2   wscript.quit 0 'Cancel, not asking again
                              case -1  'timed out, ask Input again
                       End Select
          End Select
      Loop '(end of INPUTcheck for one-of-the-only-2-options)
      '- - - end: INPUTBOX - - - - - -
      
      'do your thing:
      
        If strInput = Lcase("import") then
           strChosen = Ucase(strInput) & " ---> " & _
                             Right(sRegFile,Len(sRegFile)-InStrRev(sRegFile,"\"))
           objShell.Run "regedit.exe /s " & Chr(34) & sRegFile & Chr(34), 0, True
           
        Else 'delete the key and subkeys
           strChosen = Ucase(strInput) & " ---> " & _
                    Right(strHKLMpath,Len(strHKLMpath)-InStrRev(strHKLMpath,"\"))
           DeleteRegKey HKEY_LOCAL_MACHINE, strHKLMpath 
      
        End IF
      
      
      wscript.Echo strChosen & "      = Done!" &  vbCRLF & _
                           vbCRLF & _
      "(You may have to restart your computer to make the changes effective)"
      
      
      wscript.quit 0  'End of script!!!
      
      
      '----functions and Routines----
      
      Sub DeleteRegKey(HKEY_LOCAL_MACHINE, strHKLMpath)
       'first check... and delete subkeys if they exists
          objRegistry.EnumKey HKEY_LOCAL_MACHINE, strHKLMpath, arrSubkeys 
          If IsArray(arrSubkeys) Then 
              For Each strSubkey In arrSubkeys
                  DeleteRegKey HKEY_LOCAL_MACHINE, strHKLMpath & "\" & strSubkey 
              Next 
          End If
       'no subkeys left, now continue deleting the key it self
          objRegistry.DeleteKey HKEY_LOCAL_MACHINE, strHKLMpath
      End Sub
      Now it is even possible leaving the InputBox-part completely out of the script, if you want.

      But, if you still want to keep control over the action that is going to be taken, you can also replace the complete InputBox-part with this part;
      Code:
      '- - - begin: INPUTBOX - - - - - -
      BtnCode = objShell.Popup( _
              "Would you like to ***" & UCase(strInput) & "*** the " _
              & Right(strHKLMpath,Len(strHKLMpath)-InStrRev(strHKLMpath,"\")) _
              & " key to/from the registry?   [!]", , "Read carefully", 4)
                       Select Case BtnCode
                              case 1   'YES, change the current state
                              case 7   wscript.quit 0 'NO, abort action
                       End Select
      '- - - end: INPUTBOX - - - - - -
      Now this part shows the current state, and only asks if you want to change it to the other state Yes or No.

      \Rem

      EDIT: Note..! You have to be a member of the local group Administrators, otherwise nothing will be modified in the registry, even if the script.popup may said it has.
      Last edited by Rems; 19th February 2007, 22:30. Reason: added a 'note' about running the script

      This posting is provided "AS IS" with no warranties, and confers no rights.

      __________________

      ** Remember to give credit where credit's due **
      and leave Reputation Points for meaningful posts

      Comment

      Working...
      X