在 windows 8 月 10 日使用 visual basic 脚本启用系统保护
Enable system protection using visual basic script on windows 8/10
我正在尝试在 windows 10 上使用以下 visual basic 脚本启用系统保护。但它给出了一个错误 "access denied"。我已经搜索了关于 WMI 类 的微软文档,感觉下面的代码对于 windows 7 或 xp 是完全没问题的,但对于 windows 10 却不是,并且在花了很多时间寻找之后微软网站上的文档我无法找到有关如何执行此操作的任何线索。
注意:我正在寻找一个可视化的基本脚本,如果没有,它可以在 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")
我想通了。以下代码在windows10.
中成功启用系统保护
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:" & "\")
我正在尝试在 windows 10 上使用以下 visual basic 脚本启用系统保护。但它给出了一个错误 "access denied"。我已经搜索了关于 WMI 类 的微软文档,感觉下面的代码对于 windows 7 或 xp 是完全没问题的,但对于 windows 10 却不是,并且在花了很多时间寻找之后微软网站上的文档我无法找到有关如何执行此操作的任何线索。
注意:我正在寻找一个可视化的基本脚本,如果没有,它可以在 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")
我想通了。以下代码在windows10.
中成功启用系统保护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:" & "\")