none
Ajuda - Erro de script RRS feed

  • Pergunta

  • All,

     

    Estou com um problema no meu ambiente que gostaria de compartilhar com vcs...

     

    Trabalho com Terminal Server, utilizando o Windows 2003 Server...

    Todos os perfis dos usuarios ficam alocados neste Servidor tambem, existe 01 script que esta me dando uma dor de cabeça tremenda por 2 motivos..

     

    Primeiro nao foi eu quem fiz, e segundo não sei para que serve esse cara....

     

    A baixo vou colocar o script, toda a vez que o usuario loga aparece uma tela de erro no desktop apontando para esse script..

     

    Script:

     

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\default")
    Set objItem = objWMIService.Get("SystemRestore")

     

    Alguem poderia me ajudar a desvendar o que esse script faz....

     

    Grato,

     

    Franks

    terça-feira, 26 de junho de 2007 14:20

Respostas

  • Até agora pelo que vi o script só está criando o objeto...pelo que pude verificar no google o "objWMIService.Get("SystemRestore")", é usado para hablitar,desabilitar, criar, executar  um ponto de restauração pelo System Restore.

    Segue exemplos, procure por mais códigos no seu script:

     

    Create a System Restore Point


    Creates a new system restore point on a computer, specifying that the restore point was created prior to installing a new device driver.

    CONST DEVICE_DRIVER_INSTALL = 10
    CONST BEGIN_SYSTEM_CHANGE = 100
    
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")
    
    Set objItem = objWMIService.Get("SystemRestore")
    errResults = objItem.CreateRestorePoint _
        ("Scripted restore", DEVICE_DRIVER_INSTALL, BEGIN_SYSTEM_CHANGE)
    

     

     

    Disable Full System Restore


    Disables system restore on a computer. This is equivalent to selecting the checkbox Turn off System Restore (found by right-clicking My Computer, clicking Properties, and then clicking on the System Restore tab in the resulting dialog box).

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")
    
    Set objItem = objWMIService.Get("SystemRestore")
    errResults = objItem.Disable("")
    
     

    Enable Full System Restore


    Enables system restore on a computer. This is equivalent to clearing the checkbox Turn off System Restore (found by right-clicking My Computer, clicking Properties, and then clicking on the System Restore tab in the resulting dialog box).
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")
    
    Set objItem = objWMIService.Get("SystemRestore")
    errResults = objItem.Enable("")
    
     

    List All Existing Restore Points


    Returns a list of all system restore points stored on a computer, as well as detailed information about each of those restore points.
    Set dtmConvertedDate = CreateObject("WbemScripting.SWbemDateTime")
     
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")
    
    Set colItems = objWMIService.ExecQuery("Select * from SystemRestore")
    If colItems.Count = 0 Then
        WScript.Echo "No restore point in system."
    Else
        For Each objItem in colItems
            Wscript.Echo "Name: " & objItem.Description
            Wscript.Echo "Number: " & objItem.SequenceNumber
            Select Case objItem.RestorePointType
          Case 0 strRestoreType = "Application installation"
                Case 1 strRestoreType = "Application uninstall"
                Case 6 strRestoreType = "Restore"
                Case 7 strRestoreType = "Checkpoint"
                Case 10 strRestoreType = "Device drive installation"
                Case 11 strRestoreType = "First run"
                Case 12 strRestoreType = "Modify settings"
                Case 13 strRestoreType = "Cancelled operation"
                Case 14 strRestoreType = "Backup recovery"
                Case Else strRestoreType = "Unknown"
            End Select
            Wscript.Echo "Restore Point Type: " & strRestoreType
     
            dtmConvertedDate.Value = objItem.CreationTime
            dtmCreationTime = dtmConvertedDate.GetVarDate
            Wscript.Echo "Time: " & dtmCreationTime
         Next
    End If
    	
    

    List the Results of the Last System Restore


    Returns the results (failed, succeeded, interrupted) of the last system restore performed on a computer.
    strComputer = "."
     
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")
    
    Set objItem = objWMIService.Get("SystemRestore")
    errResults = objItem.GetLastRestoreStatus()
     
    Select Case errResults
        Case 0 strRestoreStatus = "The last restore failed."
        Case 1 strRestoreStatus = "The last restore was successful."
        Case 2 strRestoreStatus = "The last restore was interrupted."
    End Select
     
    Wscript.Echo strRestoreStatus
    	
    

    List System Restore Configuration Values


    Displays the current system restore configuration settings on a computer.
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")
    
    Set colItems = objWMIService.ExecQuery("Select * from SystemRestoreConfig")
    
    For Each objItem in colItems
        Wscript.Echo "Disk Percent: " & objItem.DiskPercent
        Wscript.Echo "Global Interval (in seconds): " & objItem.RPGlobalInterval 
        Wscript.Echo "Life Interval (in seconds): " & objItem.RPLifeInterval
        If objItem.RPSessionInterval = 0 Then
            Wscript.Echo "Session Interval: Feature not enabled." 
        Else
            Wscript.Echo "Session Interval (in seconds): " & _
                objItem.RPSessionInterval
        End If
    Next
    	
    

    Modify System Restore Configuration Values


    Modifies the system restore configuration values on a computer, setting the global interval to 100,000 seconds; the life interval to 8,000,000 seconds; and the session interval to 500,000 seconds.
    Const GLOBAL_INTERVAL_IN_SECONDS = 100000
    Const LIFE_INTERVAL_IN_SECONDS = 8000000
    Const SESSION_INTERVAL_IN_SECONDS = 500000
     
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")
    
    Set objItem = objWMIService.Get("SystemRestoreConfig='SR'")
    objItem.DiskPercent = 10
    objItem.RPGlobalInterval = GLOBAL_INTERVAL_IN_SECONDS
    objItem.RPLifeInterval = LIFE_INTERVAL_IN_SECONDS
    objItem.RPSessionInterval = SESSION_INTERVAL_IN_SECONDS
    objItem.Put_
    	
    
    Boa sorte.
    abraço.
    terça-feira, 26 de junho de 2007 18:22

Todas as Respostas

  • Até agora pelo que vi o script só está criando o objeto...pelo que pude verificar no google o "objWMIService.Get("SystemRestore")", é usado para hablitar,desabilitar, criar, executar  um ponto de restauração pelo System Restore.

    Segue exemplos, procure por mais códigos no seu script:

     

    Create a System Restore Point


    Creates a new system restore point on a computer, specifying that the restore point was created prior to installing a new device driver.

    CONST DEVICE_DRIVER_INSTALL = 10
    CONST BEGIN_SYSTEM_CHANGE = 100
    
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")
    
    Set objItem = objWMIService.Get("SystemRestore")
    errResults = objItem.CreateRestorePoint _
        ("Scripted restore", DEVICE_DRIVER_INSTALL, BEGIN_SYSTEM_CHANGE)
    

     

     

    Disable Full System Restore


    Disables system restore on a computer. This is equivalent to selecting the checkbox Turn off System Restore (found by right-clicking My Computer, clicking Properties, and then clicking on the System Restore tab in the resulting dialog box).

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")
    
    Set objItem = objWMIService.Get("SystemRestore")
    errResults = objItem.Disable("")
    
     

    Enable Full System Restore


    Enables system restore on a computer. This is equivalent to clearing the checkbox Turn off System Restore (found by right-clicking My Computer, clicking Properties, and then clicking on the System Restore tab in the resulting dialog box).
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")
    
    Set objItem = objWMIService.Get("SystemRestore")
    errResults = objItem.Enable("")
    
     

    List All Existing Restore Points


    Returns a list of all system restore points stored on a computer, as well as detailed information about each of those restore points.
    Set dtmConvertedDate = CreateObject("WbemScripting.SWbemDateTime")
     
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")
    
    Set colItems = objWMIService.ExecQuery("Select * from SystemRestore")
    If colItems.Count = 0 Then
        WScript.Echo "No restore point in system."
    Else
        For Each objItem in colItems
            Wscript.Echo "Name: " & objItem.Description
            Wscript.Echo "Number: " & objItem.SequenceNumber
            Select Case objItem.RestorePointType
          Case 0 strRestoreType = "Application installation"
                Case 1 strRestoreType = "Application uninstall"
                Case 6 strRestoreType = "Restore"
                Case 7 strRestoreType = "Checkpoint"
                Case 10 strRestoreType = "Device drive installation"
                Case 11 strRestoreType = "First run"
                Case 12 strRestoreType = "Modify settings"
                Case 13 strRestoreType = "Cancelled operation"
                Case 14 strRestoreType = "Backup recovery"
                Case Else strRestoreType = "Unknown"
            End Select
            Wscript.Echo "Restore Point Type: " & strRestoreType
     
            dtmConvertedDate.Value = objItem.CreationTime
            dtmCreationTime = dtmConvertedDate.GetVarDate
            Wscript.Echo "Time: " & dtmCreationTime
         Next
    End If
    	
    

    List the Results of the Last System Restore


    Returns the results (failed, succeeded, interrupted) of the last system restore performed on a computer.
    strComputer = "."
     
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")
    
    Set objItem = objWMIService.Get("SystemRestore")
    errResults = objItem.GetLastRestoreStatus()
     
    Select Case errResults
        Case 0 strRestoreStatus = "The last restore failed."
        Case 1 strRestoreStatus = "The last restore was successful."
        Case 2 strRestoreStatus = "The last restore was interrupted."
    End Select
     
    Wscript.Echo strRestoreStatus
    	
    

    List System Restore Configuration Values


    Displays the current system restore configuration settings on a computer.
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")
    
    Set colItems = objWMIService.ExecQuery("Select * from SystemRestoreConfig")
    
    For Each objItem in colItems
        Wscript.Echo "Disk Percent: " & objItem.DiskPercent
        Wscript.Echo "Global Interval (in seconds): " & objItem.RPGlobalInterval 
        Wscript.Echo "Life Interval (in seconds): " & objItem.RPLifeInterval
        If objItem.RPSessionInterval = 0 Then
            Wscript.Echo "Session Interval: Feature not enabled." 
        Else
            Wscript.Echo "Session Interval (in seconds): " & _
                objItem.RPSessionInterval
        End If
    Next
    	
    

    Modify System Restore Configuration Values


    Modifies the system restore configuration values on a computer, setting the global interval to 100,000 seconds; the life interval to 8,000,000 seconds; and the session interval to 500,000 seconds.
    Const GLOBAL_INTERVAL_IN_SECONDS = 100000
    Const LIFE_INTERVAL_IN_SECONDS = 8000000
    Const SESSION_INTERVAL_IN_SECONDS = 500000
     
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")
    
    Set objItem = objWMIService.Get("SystemRestoreConfig='SR'")
    objItem.DiskPercent = 10
    objItem.RPGlobalInterval = GLOBAL_INTERVAL_IN_SECONDS
    objItem.RPLifeInterval = LIFE_INTERVAL_IN_SECONDS
    objItem.RPSessionInterval = SESSION_INTERVAL_IN_SECONDS
    objItem.Put_
    	
    
    Boa sorte.
    abraço.
    terça-feira, 26 de junho de 2007 18:22
  • Franks, por favor, poste o script completo. Caso tudo que o script faça seja estas três linhas ele não está fazendo nada.

     

    sexta-feira, 31 de agosto de 2007 18:34
  • Boa Tarde!

    Romeu, gostaria de um auxilio seu.

    Não manjo muito de script, estou apanhando para criar um que realize os seguintes passos:

     

    1° - Habilite o ponto de restauração
    2° - Que utilize somente 2% do disco
    3° - De 7 em 7 dias crie um novo ponto de restauração
    4° - mantenha somente os três últimos pontos de restauração nas estações.

    Pelo exemplo que colocou acima já dá pra ter uma noção de como se constrói este script em específico, mas ficaria grato se alguém pudesse me auxiliar.

    terça-feira, 17 de março de 2009 17:36