本文介绍了用VB执行(RunspaceFactory) - 系统还原的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我已将频率更改为每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类结束命名空间 解决方案 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.AutomationImports System.Management.Automation.RunspacesImports System.Collections.ObjectModelNamespace 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 ClassEnd Namespace 解决方案 这篇关于用VB执行(RunspaceFactory) - 系统还原的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-19 15:59