none
Como Evitar RRS feed

  • Pergunta

  • Ba Galera.

    Estou rodando o vbs abaixo e gostaria que o mesmo gera-se no log somente as informaçoes que desejo que é o unico ponto que ele popula, porem alem de colocar as informações que eu quero, ele tb coloca mais coisa no log, como evitar.

    Vbs

    strComputer = "."

    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colComputer = objWMIService.ExecQuery _
        ("Select * from Win32_ComputerSystem")
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery _
        ("Select * from Win32_NetworkLoginProfile")

    For Each objComputer in colComputer
     objTextFile.WriteLine "Usuario Logado: " & objComputer.UserName  & vbCrLf
    Next   

    For Each objItem in colItems
        objTextFile.WriteLine "Caption: " & objItem.Caption
        objTextFile.WriteLine "Comment: " & objItem.Comment
        objTextFile.WriteLine "Description: " & objItem.Description
        objTextFile.WriteLine "Full Name: " & objItem.FullName
        objTextFile.WriteLine "Last Logon: " & strReturn
        objTextFile.WriteLine "Logon Hours: " & objItem.LogonHours
        objTextFile.WriteLine "Name: " & objItem.Name
        objTextFile.WriteLine "Password Age: " & objItem.PasswordAge
        objTextFile.WriteLine "Password Expires: " & strReturn
        objTextFile.WriteLine "Script Path: " & objItem.ScriptPath
    Next

    Saida de log, ( essa primeira parte é a que eu gostaria de tirar )

    Usuario Logado: dominio\usuario

    Caption: AUTORIDADE NT\SYSTEM
    Comment:
    Description: Network login profile settings for SYSTEM on AUTORIDADE NT
    Full Name:
    Last Logon:
    Logon Hours:
    Name: AUTORIDADE NT\SYSTEM
    Password Age:
    Password Expires:
    Script Path:
    Caption: AUTORIDADE NT\LOCAL SERVICE
    Comment:
    Description: Network login profile settings for LOCAL SERVICE on AUTORIDADE NT
    Full Name:
    Last Logon:
    Logon Hours:
    Name: AUTORIDADE NT\LOCAL SERVICE
    Password Age:
    Password Expires:
    Script Path:
    Caption: AUTORIDADE NT\NETWORK SERVICE
    Comment:
    Description: Network login profile settings for NETWORK SERVICE on AUTORIDADE NT
    Full Name:
    Last Logon:
    Logon Hours:
    Name: AUTORIDADE NT\NETWORK SERVICE
    Password Age:
    Password Expires:
    Script Path:

    Pate do log que ele popula, ( é a que eu desejo que fique no log sem a parte de cima )

    Caption: Usuario
    Comment: Conta de usuario
    Description: Network login profile settings for  on Estacao
    Full Name: Nome completo do usuario
    Last Logon: 09/08/2009
    Logon Hours: Sunday: No Limit -- Monday: No Limit -- Tuesday: No Limit -- Wednesday: No Limit -- Thursday: No Limit -- Friday: No Limit -- Saturday: No Limit
    Name: Dominio\Usuario
    Password Age: 00000293071036.000000:000
    Password Expires: 26/09/2009
    Script Path: script.bat

    terça-feira, 11 de agosto de 2009 00:00

Respostas

  • Olá,


    Faça os testes no script abaixo:


    strComputer = "."
    Set FileSystem = WScript.CreateObject("Scripting.FileSystemObject")

    Set objTextFile = FileSystem.OpenTextFile("log.txt", 8, True, 0)

    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

    Set colComputer = objWMIService.ExecQuery _
        ("Select * from Win32_ComputerSystem")

    strUsuario = ""

    For Each objComputer in colComputer
     objTextFile.WriteLine "Usuario Logado: " & objComputer.UserName  & vbCrLf
       strUsuario = objComputer.UserName
    Next  
    strUsuario = split(strUsuario, "\")

    Set colItems = objWMIService.ExecQuery _
        ("Select * from Win32_NetworkLoginProfile where caption = '" & strUsuario(UBOUND(strUsuario)) & "'")


    For Each objItem in colItems
        objTextFile.WriteLine "Caption: " & objItem.Caption
        objTextFile.WriteLine "Comment: " & objItem.Comment
        objTextFile.WriteLine "Description: " & objItem.Description
        objTextFile.WriteLine "Full Name: " & objItem.FullName
        objTextFile.WriteLine "Last Logon: " & strReturn
        objTextFile.WriteLine "Logon Hours: " & objItem.LogonHours
        objTextFile.WriteLine "Name: " & objItem.Name
        objTextFile.WriteLine "Password Age: " & objItem.PasswordAge
        objTextFile.WriteLine "Password Expires: " & strReturn
        objTextFile.WriteLine "Script Path: " & objItem.ScriptPath
    Next





    Até mais,

    Jesiel

    Obs.: Se útil, classifique

    • Marcado como Resposta Marcelo TI quarta-feira, 12 de agosto de 2009 00:19
    terça-feira, 11 de agosto de 2009 01:17

Todas as Respostas

  • Olá,


    Faça os testes no script abaixo:


    strComputer = "."
    Set FileSystem = WScript.CreateObject("Scripting.FileSystemObject")

    Set objTextFile = FileSystem.OpenTextFile("log.txt", 8, True, 0)

    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

    Set colComputer = objWMIService.ExecQuery _
        ("Select * from Win32_ComputerSystem")

    strUsuario = ""

    For Each objComputer in colComputer
     objTextFile.WriteLine "Usuario Logado: " & objComputer.UserName  & vbCrLf
       strUsuario = objComputer.UserName
    Next  
    strUsuario = split(strUsuario, "\")

    Set colItems = objWMIService.ExecQuery _
        ("Select * from Win32_NetworkLoginProfile where caption = '" & strUsuario(UBOUND(strUsuario)) & "'")


    For Each objItem in colItems
        objTextFile.WriteLine "Caption: " & objItem.Caption
        objTextFile.WriteLine "Comment: " & objItem.Comment
        objTextFile.WriteLine "Description: " & objItem.Description
        objTextFile.WriteLine "Full Name: " & objItem.FullName
        objTextFile.WriteLine "Last Logon: " & strReturn
        objTextFile.WriteLine "Logon Hours: " & objItem.LogonHours
        objTextFile.WriteLine "Name: " & objItem.Name
        objTextFile.WriteLine "Password Age: " & objItem.PasswordAge
        objTextFile.WriteLine "Password Expires: " & strReturn
        objTextFile.WriteLine "Script Path: " & objItem.ScriptPath
    Next





    Até mais,

    Jesiel

    Obs.: Se útil, classifique

    • Marcado como Resposta Marcelo TI quarta-feira, 12 de agosto de 2009 00:19
    terça-feira, 11 de agosto de 2009 01:17
  • Ba tche.

    Boa noite Jesiel

    Rolou legal.

    Abraço.
    quarta-feira, 12 de agosto de 2009 00:19