コード例 #1
0
        public override Process CreateProcess(List <string> procParams, IList <IXenObject> targets)
        {
            Registry.AssertPowerShellInstalled();
            Registry.AssertPowerShellExecutionPolicyNonRestricted();

            string command = MakeInvocationExpression(Filename, Function, procParams, Params, targets, Debug);

            //escape the entire command statement as it is being passed into the -Command parameter in quotes
            command = EscapeQuotes(EscapeBackSlashes(command));

            return(new Process
            {
                StartInfo =
                {
                    FileName        = PluginDescriptor.PowerShellExecutable,
                    Arguments       = $"-NoLogo -Command \"Import-Module XenServerPSModule; {command}\"",
                    UseShellExecute = false,
                    CreateNoWindow  = !Window,
                    WindowStyle     = Window ? ProcessWindowStyle.Normal : ProcessWindowStyle.Hidden
                }
            });
        }