用VB执行(RunspaceFactory) - 系统还原 [英] Executing with VB (RunspaceFactory) - System restore
问题描述
我已将频率更改为每24小时允许超过一次。我的vb执行没有例外,但没有创建新的点。
任何想法?
Imports System.Management.Automation
Imports System.Management.Automation.Runspaces
Imports System.Collections.ObjectModel
Namespace Classes.Powershell
' ''< summary>
'''
'''< / summary>
Public Class SystemRestore
'''< summary>
'''
'''< / summary>
朋友共享子创建()
Console.WriteLine("请求还原点。")
'使用创建RunSpace来托管Powershell脚本环境
'RunspaceFactory.CreateRunSpace
Dim runSpace As Runspace = RunspaceFactory.CreateRunspace()
runSpace.Open()
'创建一个管道来托管要执行的命令
'Runnspace.CreatePipeline
Dim pipeLine As Pipeline = runSpace.CreatePipeline()
Dim getProcessCStarted As New Command(" Checkpoint-Computer")
'创建一个Co
getProcessCStarted.Parameters.Add(" -Description"," Test")
'将命令添加到管道
pipeLine.Commands.Add(getProcessCStarted)
'通过调用Pipel在当前管道中运行所有命令ine.Invoke。
'它返回一个System.Collections.ObjectModel.Collection对象
'在这个例子中,执行的脚本是"Get-Process -name V *"。
Dim vNameProcesses As Collection(Of PSObject)= pipeLine.Invoke()
Console.WriteLine(" done")
End Sub
End类
结束命名空间
这不是VB论坛。
以下行错误:
getProcessCStarted 。 强> 跨度> <跨度>的参数强> 跨度> <跨度> 即可。强> 跨度> <跨度> 添加强> < /跨度> <跨度> (适用强> 跨度> <跨度> <强>" -Description" 强> 跨度> <跨度> 下,强>
"测试" )
请勿使用短划线" - "在参数名称中。
此代码必须运行提升。
注意:"从Windows 8开始,Checkpoint-Computer无法创建超过每天一个检查点。"
Hi, I have changed the frequency to allow more than One per 24 hours. My vb executes without exceptions but does not create a new point.
Any ideas?
Imports System.Management.Automation Imports System.Management.Automation.Runspaces Imports System.Collections.ObjectModel Namespace Classes.Powershell ''' <summary> ''' ''' </summary> Public Class SystemRestore ''' <summary> ''' ''' </summary> Friend Shared Sub Create() Console.WriteLine("Requesting restore point.") ' Create a RunSpace to host the Powershell script environment using ' RunspaceFactory.CreateRunSpace Dim runSpace As Runspace = RunspaceFactory.CreateRunspace() runSpace.Open() ' Create a Pipeline to host commands to be executed using ' Runspace.CreatePipeline Dim pipeLine As Pipeline = runSpace.CreatePipeline() Dim getProcessCStarted As New Command("Checkpoint-Computer") ' Create a Co getProcessCStarted.Parameters.Add("-Description", "Test") ' Add the commands to the Pipeline pipeLine.Commands.Add(getProcessCStarted) ' Run all commands in the current pipeline by calling Pipeline.Invoke. ' It returns a System.Collections.ObjectModel.Collection object ' In this example, the executed script is "Get-Process -name V*". Dim vNameProcesses As Collection(Of PSObject) = pipeLine.Invoke() Console.WriteLine("done") End Sub End Class End Namespace
This is not a VB forum.
The following line is wrong:
getProcessCStarted.Parameters.Add("-Description", "Test")
Do not use a dash "-" in the parameter name.
This code must be run elevated.
Note: "Beginning in Windows 8, Checkpoint-Computer cannot create more than one checkpoint each day."
这篇关于用VB执行(RunspaceFactory) - 系统还原的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!