2

I have

C:\folder\tail.exe

C:\logs\logfile.log

C:\script\shellscript.ps1

How do I run the C:\folder\tail.exe from within the C:\script\shellscript.ps1

I need to run "C:\folder\tailf.exe C:\logs\logfile.log" from within C:\script\shellscript.ps1 but without relying a seperate batch file, i need to call it directly.

Normally I do: cd C:\folder\ and then tailf.exe C:\logs\logfile.log

Inside C:\script\shellscript.ps1 I tried

start-process C:\fetchmail\tail.exe -argumentlist "C:\fetchmail\logs\fetchmail.log"

i can see a window flashing but dont know if it works, the window should stay open.

2 Answers 2

7

You can do what you normally do:

C:\folder\tail.exe c:\logs\logfile.log

Note that if the paths have spaces in them you have to do:

& "C:\fol der\tail.exe" "c:\log s\logfile.log"
Sign up to request clarification or add additional context in comments.

Comments

3
  1. To accomplish tail.exe running in a separate window and not having the window closed immediately, try:

    cmd /k c:\folder\tail.exe c:\logs\test.log

  2. To start tail.exe in the powershell window, try:

    C:\folder\tail.exe c:\logs\logfile.log

  3. Assuming tail.exe is Tail for Win32, this is a powershell equivalent of your command:

    get-content c:\logs\logfile.log | select -last 10

  4. In the Powershell Community Extensions there is a Get-FileTail cmdlet which is a more efficient native powershell tail equivalent.

1 Comment

You can just type cmd /k c:\folder\tail.exe c:\logs\test.log in PowerShell. It's a shell after all. There are some idiosyncrasies with arguments to programs but they don't apply here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.