cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
MacPhail
Engaged Sweeper

The code below gets a listing of restore points on a remote computer. I'm trying to get it to output the data in a single window. Now it's a window per line.

I'm not good with VBS so any help is appreciated.

Chris


Set dtmConvertedDate = CreateObject("WbemScripting.SWbemDateTime")

strComputer = WScript.Arguments(0)
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
1 REPLY 1
KrisNelson
Champion Sweeper
In most cases it's best to gather all the information you want and then do something with it (in this case output it to a message box).

Try this:

Set dtmConvertedDate = CreateObject("WbemScripting.SWbemDateTime") 

strComputer = WScript.Arguments(0)

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
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
dtmConvertedDate.Value = objItem.CreationTime
dtmCreationTime = dtmConvertedDate.GetVarDate
Wscript.Echo "Name: " & objItem.Description & vbcrlf & "Number: " & objItem.SequenceNumber & vbcrlf & "Restore Point Type: " & strRestoreType & vbcrlf & "Time: " & dtmCreationTime
Next
End If


-Kris

New to Lansweeper?

Try Lansweeper For Free

Experience Lansweeper with your own data.
Sign up now for a 14-day free trial.

Try Now