Hecadikof
Hecadikof

Reputation: 3

Ping is not saving to file

I try to type command:

start "xyz" ping xx.xx.xx.xx >> C:\Users\X\Desktop\t\xyz.txt 

It creates empty file. What am i missing ? Thanks.

Upvotes: 0

Views: 58

Answers (2)

Stephan
Stephan

Reputation: 56198

Your problem is, that you redirect the output of start to the file. You have to "link" the redirection to the cmd instead.

Either (as Liturgist already answered) by escaping the >>:

start "xyz" cmd.exe /C ping localhost ^>^>xyz.txt

or by enclosing your "executed string" into quotes:

start "xyz" cmd.exe /C "ping localhost >>xyz.txt"

Upvotes: 1

lit
lit

Reputation: 16256

You need to escape the redirection characters.

start "xyz" cmd.exe /C ping localhost ^>^>xyz.txt

Upvotes: 0

Related Questions