1

I have a C# console application that reads .csv files. I want to run this in the middle of a powershell script. What is the best way to do this?

2
  • social.technet.microsoft.com/wiki/contents/articles/… Commented Jun 12, 2015 at 19:21
  • Thank you for the responses everyone. I'm new to this stuff so sorry for the duplicate question. I tried looking but couldn't find an answer to my question. Cheers! Commented Jun 12, 2015 at 19:50

3 Answers 3

3

If your executable isn't in your path you will need to tell powershell where to find it.

& "c:\some path with spaces\foo.exe" <arguments go here>

This has been answered before, here: Executing an EXE file using a PowerShell script

Sign up to request clarification or add additional context in comments.

Comments

2

Use Start-Process, perhaps with the -PassThru option, for example:

$csvProc = Start-Process my_csv_reader.exe -PassThru

This would allow you to do something like $csvProc | Stop-Process later on, or to check if it's still running at a later point in your script through $csvProc.HasExited

If you need even more control, you could do it this way:

$csvProc = New-Object System.Diagnostics.ProcessStartInfo

and then you can use $csvProc the same way you'd use ProcessStartInfo in C# (setting the file name, paramaters, redirecting standard in or out, starting the process, etc.).

Comments

1

Easy:

Start-Process -Wait PathToFile

If you don't want to wait for the process to finish remove the "-Wait" switch.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.