maniG
Content Type
Profiles
Forums
Events
Posts posted by maniG
-
-
On 6/16/2017 at 9:37 PM, gunsmokingman said:
I am not sure what you want but using this reference https://msdn.microsoft.com/en-us/library/windows/desktop/aa378858(v=vs.85).aspx
I put together this script run it and see if it what you need.
Dim d,oWMI, oSR, colItem, objItem Set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") Set oSR = GetObject("winmgmts:{impersonationLevel=impersonate}!root/default:SystemRestore") Set colItem = oWMI.ExecQuery("SELECT * FROM Win32_LogicalDisk WHERE DriveType=3") On Error Resume Next For Each objItem In colItem d = objItem.Name & "\" If (oSR.Enable(d)) = 0 Then wscript.Echo "Success" & vbTab & d Else wscript.Echo "Failed " & vbTab & d End If Next
Hey thankyou for the answer. I have made changes to the code. Basically before we create a restore point, system restore must be enabled and I wanted to know a way to check if it is enabled or not.
0 -
I am using the following code in my visual basic script to enable system protection in windows 10 and it works perfectly fine. I am looking for a visual basic code that checks if protection on particular drive is enabled or not?
and Sets Max usage to 15%.
If Not WScript.Arguments.Named.Exists("elevate") Then CreateObject("Shell.Application").ShellExecute WScript.FullName _ , WScript.ScriptFullName & " /elevate", "", "runas", 1 WScript.Quit End If Dim oSR Set oSR = GetObject("winmgmts:{impersonationLevel=impersonate}!root/default:SystemRestore") oSR.Enable("C:" & "\")
If someone can highlight the version of windows this code is compatible for, that would be great.
0
How to check if system protection is enabled on a drive
in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Posted
That seems to be a good way to check. So far what I have done is my script will attempt to create a restore point and in case of error it will call a function that will enable protection and then again create a restore point or will exit in case of success. Thank you for your help.