我试图在windows 10上使用下面的visual basic脚本启用系统保护,但是它提供了一个“拒绝访问”错误。我已经搜索过有关WMI类的microsoft文档,感觉下面的代码对于windows 7或xp来说是非常好的,但对于windows 10则不行。在花了大量时间在microsoft的网站上查找文档之后,我还没有找到如何这样做的任何线索。
注意:我正在寻找一个可视化的基本脚本ony,如果不是的话,可以在windows 10上进行保护。
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")
Set objItem = objWMIService.Get("SystemRestore")
errResults = objItem.Enable("D:\")
'Inform User that the task is done.
Mybox = MsgBox("System Restore is now enabled on "& strComputer &"" &
vbCRLF ,vbOkOnly,"System Restore Enabled")
发布于 2017-06-15 08:28:59
我已经猜到了。以下代码成功地启用了windows 10中的系统保护。
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("D:" & "\")
https://stackoverflow.com/questions/44555278
复制相似问题