Script para Habilitar os Compartilhamentos Administrativos

Posted on 4 de novembro de 2015

0


Script desenvolvido para recriar os compartilhamentos administrativos
Testado no Windows 7


‘ Autor:            Eder Machado | edermachadoo.wordpress.com
‘ Criação:          04/11/2015
‘ Validação:        -
‘ Alterado :        Eder Machado | edermachadoo.wordpress.com
‘ Ultima Atualização:   04/11/2015
‘ Script para Habilitar os Compartilhamentos Administrativos
‘_______________________________________________________________________________________________________________________

Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = ”.”

call setRegistry(“SYSTEM\CurrentControlSet\Services\lanmanserver\parameters\”,”AutoShareWks”,1)

Function SetRegistry(strKeyPath,strValueName,intValue)
Set oReg=GetObject( ”winmgmts:{impersonationLevel=impersonate}!\\” & strComputer & ”\root\default:StdRegProv”)

oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,intValue

End function

Set objWMIService = GetObject(“winmgmts:{impersonationLevel=impersonate}!\\” & strComputer & ”\root\cimv2”)
Set objLanManServer = objWMIService.Get(“Win32_Service.Name=’LanManServer'”)
Set colServiceList = objWMIService.ExecQuery(“Associators of ” _
& ”{Win32_Service.Name=’LanManServer’} Where ” _
& ”AssocClass=Win32_DependentService ” & _
“Role=Antecedent” )
For Each objService in colServiceList
objService.StopService()
Next
‘Tempo para aguardar o serviço finalizar
WScript.Sleep 20000
Return = objLanManServer.StopService()
‘Tempo para iniciar o serviço
WScript.Sleep 10000
Return = objLanManServer.StartService()
For Each objService in colServiceList
objService.StartService()
Next

Posted in: Script VBS