Page 1 of 1

Iterate through CSV for System.Diagnostics.Process object

Posted: Mon Sep 17, 2018 8:38 am
by njcappa
Hi All,

I'm attempting to use the attached psf (which invokes the System.Diagnostics.Process object), to run an exe and output the results. In the example psf, the "$process.StartInfo.Arguments" value calls arguments for ping, but what actually I need to do is to have it call a value from a foreach object which imports a CSV file.

Usually, I'd just type this:

Code: Select all

$Images = Import-csv $InputFile | ForEach-Object { }
and in the brackets, I'd call the EXE and give it the $_. data from the CSV. This is what my code does now, but it also locks up the form which is something I want to avoid.

Is the above possible using the diagnostic process object?

thanks!

Re: Iterate through CSV for System.Diagnostics.Process object

Posted: Mon Sep 17, 2018 1:32 pm
by jvierra
Hi njcappa,

You have posted the code from another thread that runs a process asynchronously. You need to post an example of your code.

Also not that a process is not a good way to execute PowerShell code. It is good for non-PS programs. For PS code use a job, workspace or runspace.