locked
Process.start is slow compared to Powershell Start-Process RRS feed

  • Question

  • I wrote a command line program to create a process and run a simulation in the background. This worked fine for many years but IT pushed something to our computers and it no longer works efficiently.  I use this program to start 200+ simulation runs and as they queued up, they would use 100% loading all my workstation 40 cores until they finished in about 15 seconds. I am not sure what IT pushed to our computers but now I can only get about a 30% usage of my cores and takes 45 seconds to complete.  The program only gets about 12 or so simulations running simultaneously.  So I tried using Start-Process in powershell and low and behold, it would queue up enough simulations to run to load all 40 cores to 100%.  Can anyone tell my how I can get the Process.start to use all of the processing power.  IT does not know what has changed to cause the issue.  It is a policy setting as IT did test a clean computer without the required policy settings and the Process.Start was able to load all of the cores.

    Here is the code I used to start running a single process in C#.

            try
            {
              Process process = new Process();
    
              if (optionHidden)
              {
                process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
              }
    
              process.StartInfo.FileName = application;
    
              process.StartInfo.Arguments = arguments;
    
              process.Start();
    
              if (optionWait)
              {
                process.WaitForExit();
              }
            }
    
            catch (Exception e)
            {
              Console.WriteLine("Failed to launch {0} because of {1}", application, e.Message);
            }
    

    The application name is nStart and looks like this to start all of the simulation runs.

    nStart /hidden nDOF.exe MM0000.ndof
    nStart /hidden nDOF.exe MM0001.ndof
    nStart /hidden nDOF.exe MM0002.ndof
    nStart /hidden nDOF.exe MM0003.ndof

    .

    .

    The powershell script looks like this.

    Start-Process .\nDOF.exe  -ArgumentList 'MM0000.ndof'
    Start-Process .\nDOF.exe  -ArgumentList 'MM0001.ndof'
    Start-Process .\nDOF.exe  -ArgumentList 'MM0002.ndof'
    Start-Process .\nDOF.exe  -ArgumentList 'MM0003.ndof'

    .

    .

    .

    Wednesday, April 18, 2018 5:17 PM

All replies

  • Is any impact if you set ‘process.StartInfo.UseShellExecute = false’?

    Wednesday, April 18, 2018 7:02 PM
  • Thanks for the idea.

    I just tried it and there was no difference. I also tried "start" in a Command Prompt and that started each simulation fast enough to load the overall CPU to 100%.  I am guessing there is some sore of StartInfo parameter I need to set but I have not successfully figured out what that parameter may be.

    Wednesday, April 18, 2018 8:34 PM
  • Hello conrarn,

    Maybe you could check the below document.

    https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/start-process?view=powershell-6

    Best Regards,

    Neil Hu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, April 23, 2018 9:57 AM