none
exclusão de atalho de forma automática RRS feed

  • Pergunta

  • Bom dia PessoALL,

    Preciso excluir um atalho que foi criado dentro da pasta All Users de todas as estações de uma OU, alguém saberia como fazer isso?

    Obrigado,

    Marciel Oliveira

     

    quinta-feira, 21 de setembro de 2006 12:37

Respostas

  • Segue o script, basta alterar  o LDAP do domíno e o nome do atalho

     

    Const ADS_SCOPE_SUBTREE = 2

    Set objConnection = CreateObject("ADODB.Connection")
    Set objCommand =   CreateObject("ADODB.Command")
    objConnection.Provider = "ADsDSOObject"
    objConnection.Open "Active Directory Provider"
    Set objCommand.ActiveConnection = objConnection

    objCommand.Properties("Page Size") = 1000
    objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

    objCommand.CommandText = _
            "SELECT distinguishedName FROM 'LDAP://OU=Computers,DC=nwtraders,DC=msft' WHERE objectCategory='Computer'"
    Set objRecordSet = objCommand.Execute
    objRecordSet.MoveFirst

    Do Until objRecordSet.EOF


    strPath = objRecordSet.Fields("distinguishedName").Value
      
      x=("LDAP://"&strpath)
      Set objComp = GetObject(x)
      
      strComputer = (objcomp.cn)
      
     aMachines = split(strComputer)
     
     For Each machine in aMachines
        Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._
            ExecQuery("select * from Win32_PingStatus where address = '"_
                & machine & "'")
       
        For Each objStatus in objPing
            If IsNull(objStatus.StatusCode) or objStatus.StatusCode<>0 Then
               
                wscript.echo (strcomputer)
                          
        else
        
        bForce = "True"
      bUpdateProfile = "True" 
        
        Set oNet = CreateObject("WScript.Network")
      oNet.RemoveNetworkDrive "X:", bForce, bUpdateProfile
      oNet.MapNetworkDrive "X:","\\"&strcomputer & "c$\Documents and Settings\All Users\Desktop"
      
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      objFSO.DeleteFile("X:\Atalho.url")

      oNet.RemoveNetworkDrive "X:", bForce, bUpdateProfile
      
      
      
      End If
        Next
     Next  


     objRecordSet.MoveNext
    Loop

    quinta-feira, 21 de setembro de 2006 12:40