Deletando Entradas Desabilitadas no MSCONFIG


/ Published in: Visual Basic
Save to your folder(s)

Este script em vbs deleta entradas desabilitadas no msconfig


Copy this code and paste it in your HTML
  1. 'Kelly's Korner 2003
  2. 'Special thanks to MVP Bill James
  3.  
  4. Set oReg = GetObject("winmgmts:!root/default:StdRegProv")
  5. Const HKLM = &H80000002
  6. RegKeySUF = "SOFTWARE\Microsoft\Shared Tools\MSConfig\startupfolder"
  7. RegKeySUR = "SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg"
  8.  
  9. ResultsSUF = EnumKey(HKLM, RegKeySUF, False)
  10. If ResultsSUF = "" Then
  11. ResultsSUF = space(5) & "(nenhum)"
  12. iBtns = 0
  13. Else
  14. iBtns = 4
  15. sDelPrompt = "Você gostaria de selecionar os itens a excluir?"
  16. End If
  17. sResults = "Itens desabilitados no menu Inicializar:" & vbcrlf & _
  18. ResultsSUF & vbcrlf & vbcrlf
  19.  
  20. ResultsSUR = EnumKey(HKLM, RegKeySUR, False)
  21. If ResultsSUR = "" Then
  22. ResultsSUR = space(5) & "(nenhum)"
  23. If iBtns <> 4 Then iBtns = 0
  24. Else
  25. iBtns = 4
  26. sDelPrompt = "Você gostaria de selecionar os itens a excluir?"
  27. End If
  28. sResults = sResults & "Itens de inicialização desabilitados:" & vbcrlf & _
  29. ResultsSUR & vbcrlf & vbcrlf
  30.  
  31. If MsgBox(sResults & sDelPrompt, iBtns + 256) <> 6 Then WScript.quit
  32.  
  33. EnumKey HKLM, RegKeySUF, True
  34. EnumKey HKLM, RegKeySUR, True
  35.  
  36. Function EnumKey(Key, SubKey, bDelete)
  37. Dim Ret()
  38. oReg.EnumKey Key, SubKey, sKeys
  39.  
  40. On Error Resume Next
  41.  
  42. ReDim Ret(UBound(sKeys))
  43. If Err = 13 Then Exit Function
  44. On Error GoTo 0
  45.  
  46. For Count = 0 to UBound(sKeys)
  47. If Not bDelete Then
  48. 'this branch used on first call
  49. Ret(Count) = space(5) & sKeys(Count)
  50. Else
  51. 'this branch used on deletion iteration
  52. If MsgBox("Você deseja excluir " & sKeys(Count) & "?" & vbcrlf & _
  53. vbcrlf & "Esta operação não pode ser desfeita!", 4 + 256) = 6 Then
  54. DeleteKey HKLM, SubKey & "\" & sKeys(Count)
  55. End If
  56. End If
  57. Next
  58. EnumKey = Join(Ret, vbcrlf)
  59. End Function
  60.  
  61. Function DeleteKey(Key, SubKey)
  62. DeleteKey = oReg.DeleteKey(Key, SubKey)
  63. End Function
  64.  
  65. Set ws = WScript.CreateObject("WScript.Shell")

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.