Return to Snippet

Revision: 18029
at September 21, 2009 21:35 by idicbr


Updated Code
'Kelly's Korner 2003
'Special thanks to MVP Bill James 

Set oReg = GetObject("winmgmts:!root/default:StdRegProv")
Const HKLM = &H80000002
RegKeySUF = "SOFTWARE\Microsoft\Shared Tools\MSConfig\startupfolder"
RegKeySUR = "SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg"

ResultsSUF = EnumKey(HKLM, RegKeySUF, False)
If ResultsSUF = "" Then
  ResultsSUF = space(5) & "(nenhum)"
  iBtns = 0
Else
  iBtns = 4
  sDelPrompt = "Você gostaria de selecionar os itens a excluir?"
End If
sResults = "Itens desabilitados no menu Inicializar:" & vbcrlf & _
           ResultsSUF & vbcrlf & vbcrlf

ResultsSUR = EnumKey(HKLM, RegKeySUR, False)
If ResultsSUR = "" Then
  ResultsSUR = space(5) & "(nenhum)"
  If iBtns <> 4 Then iBtns = 0
Else
  iBtns = 4
  sDelPrompt = "Você gostaria de selecionar os itens a excluir?"
End If
sResults = sResults & "Itens de inicialização desabilitados:" & vbcrlf & _
           ResultsSUR & vbcrlf & vbcrlf

If MsgBox(sResults & sDelPrompt, iBtns + 256) <> 6 Then WScript.quit

EnumKey HKLM, RegKeySUF, True
EnumKey HKLM, RegKeySUR, True

Function EnumKey(Key, SubKey, bDelete)
	Dim Ret()
	oReg.EnumKey Key, SubKey, sKeys

  On Error Resume Next
  
	ReDim Ret(UBound(sKeys))
  If Err = 13 Then Exit Function
  On Error GoTo 0

	For Count = 0 to UBound(sKeys)
	  If Not bDelete Then
	    'this branch used on first call
  		Ret(Count) = space(5) & sKeys(Count)
		Else
		  'this branch used on deletion iteration
		  If MsgBox("Você deseja excluir " & sKeys(Count) & "?" & vbcrlf & _
		            vbcrlf & "Esta operação não pode ser desfeita!", 4 + 256) = 6 Then
        DeleteKey HKLM, SubKey & "\" & sKeys(Count)
		  End If
  	End If
	Next
	EnumKey = Join(Ret, vbcrlf)
End Function

Function DeleteKey(Key, SubKey)
	DeleteKey = oReg.DeleteKey(Key, SubKey)
End Function

Set ws = WScript.CreateObject("WScript.Shell")

Revision: 18028
at September 21, 2009 21:33 by idicbr


Updated Code
'Kelly's Korner 2003
'Special thanks to MVP Bill James 

Set oReg = GetObject("winmgmts:!root/default:StdRegProv")
Const HKLM = &H80000002
RegKeySUF = "SOFTWARE\Microsoft\Shared Tools\MSConfig\startupfolder"
RegKeySUR = "SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg"

ResultsSUF = EnumKey(HKLM, RegKeySUF, False)
If ResultsSUF = "" Then
  ResultsSUF = space(5) & "(nenhum)"
  iBtns = 0
Else
  iBtns = 4
  sDelPrompt = "Você gostaria de selecionar os itens a excluir?"
End If
sResults = "Itens desabilitados no menu Inicializar:" & vbcrlf & _
           ResultsSUF & vbcrlf & vbcrlf

ResultsSUR = EnumKey(HKLM, RegKeySUR, False)
If ResultsSUR = "" Then
  ResultsSUR = space(5) & "(nenhum)"
  If iBtns <> 4 Then iBtns = 0
Else
  iBtns = 4
  sDelPrompt = "Você gostaria de selecionar os itens a excluir?"
End If
sResults = sResults & "Itens de inicialização desabilitados:" & vbcrlf & _
           ResultsSUR & vbcrlf & vbcrlf

If MsgBox(sResults & sDelPrompt, iBtns + 256) <> 6 Then WScript.quit

EnumKey HKLM, RegKeySUF, True
EnumKey HKLM, RegKeySUR, True

Function EnumKey(Key, SubKey, bDelete)
	Dim Ret()
	oReg.EnumKey Key, SubKey, sKeys

  On Error Resume Next
  
	ReDim Ret(UBound(sKeys))
  If Err = 13 Then Exit Function
  On Error GoTo 0

	For Count = 0 to UBound(sKeys)
	  If Not bDelete Then
	    'this branch used on first call
  		Ret(Count) = space(5) & sKeys(Count)
		Else
		  'this branch used on deletion iteration
		  If MsgBox("Você deseja excluir " & sKeys(Count) & "?" & vbcrlf & _
		            vbcrlf & "Esta operação não pode ser desfeita!", 4 + 256) = 6 Then
        DeleteKey HKLM, SubKey & "\" & sKeys(Count)
		  End If
  	End If
	Next
	EnumKey = Join(Ret, vbcrlf)
End Function

Function DeleteKey(Key, SubKey)
	DeleteKey = oReg.DeleteKey(Key, SubKey)
End Function

Set ws = WScript.CreateObject("WScript.Shell")

Revision: 18027
at September 21, 2009 21:32 by idicbr


Initial Code
'Kelly's Korner 2003
'Special thanks to MVP Bill James 

Set oReg = GetObject("winmgmts:!root/default:StdRegProv")
Const HKLM = &H80000002
RegKeySUF = "SOFTWARE\Microsoft\Shared Tools\MSConfig\startupfolder"
RegKeySUR = "SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg"

ResultsSUF = EnumKey(HKLM, RegKeySUF, False)
If ResultsSUF = "" Then
  ResultsSUF = space(5) & "(nenhum)"
  iBtns = 0
Else
  iBtns = 4
  sDelPrompt = "Você gostaria de selecionar os itens a excluir?"
End If
sResults = "Itens desabilitados no menu Inicializar:" & vbcrlf & _
           ResultsSUF & vbcrlf & vbcrlf

ResultsSUR = EnumKey(HKLM, RegKeySUR, False)
If ResultsSUR = "" Then
  ResultsSUR = space(5) & "(nenhum)"
  If iBtns <> 4 Then iBtns = 0
Else
  iBtns = 4
  sDelPrompt = "Você gostaria de selecionar os itens a excluir?"
End If
sResults = sResults & "Itens de inicialização desabilitados:" & vbcrlf & _
           ResultsSUR & vbcrlf & vbcrlf

If MsgBox(sResults & sDelPrompt, iBtns + 256) <> 6 Then WScript.quit

EnumKey HKLM, RegKeySUF, True
EnumKey HKLM, RegKeySUR, True

Function EnumKey(Key, SubKey, bDelete)
	Dim Ret()
	oReg.EnumKey Key, SubKey, sKeys

  On Error Resume Next
  
	ReDim Ret(UBound(sKeys))
  If Err = 13 Then Exit Function
  On Error GoTo 0

	For Count = 0 to UBound(sKeys)
	  If Not bDelete Then
	    'this branch used on first call
  		Ret(Count) = space(5) & sKeys(Count)
		Else
		  'this branch used on deletion iteration
		  If MsgBox("Você deseja excluir " & sKeys(Count) & "?" & vbcrlf & _
		            vbcrlf & "Esta operação não pode ser desfeita!", 4 + 256) = 6 Then
        DeleteKey HKLM, SubKey & "\" & sKeys(Count)
		  End If
  	End If
	Next
	EnumKey = Join(Ret, vbcrlf)
End Function

Function DeleteKey(Key, SubKey)
	DeleteKey = oReg.DeleteKey(Key, SubKey)
End Function

Set ws = WScript.CreateObject("WScript.Shell")

Initial URL


Initial Description
Este script em vbs deleta entradas desabilitadas no msconfig

Initial Title
Deletando Entradas Desabilitadas no MSCONFIG

Initial Tags


Initial Language
Visual Basic