Mass Ping .Bat file Writing, output to a .txt

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
knakpete
Posts: 5
Joined: 21 May 2013 02:26

Mass Ping .Bat file Writing, output to a .txt

#1 Post by knakpete » 21 May 2013 02:31

Hi, we got around 600 computers here where I work and I wanna check which are online.
Since some arent used but are set up and so on.

Ping Computer1 > "C:\PingResults.txt"
Ping Computer2 >> "C:\PingResults.txt"
Ping Computer3 >> "C:\PingResults.txt"
Ping Computer4 >> "C:\PingResults.txt"
Ping Computer5 >> "C:\PingResults.txt"

the out put is

C:\Users\knakpete\Desktop>Ping Computer1 1>"C:\PingResults.txt"
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.


Any ideas?

BR
Kim Petersson , Sweden

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Mass Ping .Bat file Writing, output to a .txt

#2 Post by foxidrive » 21 May 2013 03:11

Did you call it ping.bat ?

knakpete
Posts: 5
Joined: 21 May 2013 02:26

Re: Mass Ping .Bat file Writing, output to a .txt

#3 Post by knakpete » 21 May 2013 04:22

No I didn't since I know I cant call it that. I call it something like "MassPingFileForProduction.bat" or so. :)

Best Regards

Kim Petersson, Sweden

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Mass Ping .Bat file Writing, output to a .txt

#4 Post by foxidrive » 21 May 2013 05:10

Reboot your computer and try it again. Something is holding "C:\PingResults.txt" open.

knakpete
Posts: 5
Joined: 21 May 2013 02:26

Re: Mass Ping .Bat file Writing, output to a .txt

#5 Post by knakpete » 21 May 2013 07:33

Already did,

Best Regards

Kim Petersson, Sweden

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Mass Ping .Bat file Writing, output to a .txt

#6 Post by foxidrive » 21 May 2013 08:44

if you open a cmd prompt in the same folder as the batch file, can you enter a ping command? There may be a second ping executable somewhere (bat/cmd/exe/com) or on the path.

You didn't show the exact batch file so it could be something else in your batch file too.

knakpete
Posts: 5
Joined: 21 May 2013 02:26

Re: Mass Ping .Bat file Writing, output to a .txt

#7 Post by knakpete » 21 May 2013 23:09

Its the exact batch file. only that i Have like 200 more lines of the smae thing except a new computer name.

Im quite sure it has nothing to do that something else is yousing it already. I think there is something I need to put in betweeen the ping lines to wait the command out.


Best Regards

Kim Petersson, Sweden

knakpete
Posts: 5
Joined: 21 May 2013 02:26

Re: Mass Ping .Bat file Writing, output to a .txt

#8 Post by knakpete » 21 May 2013 23:12

SOLVED IT.

The TXT file caused a problem when put directly on the C:\ for some reason. I changed it to another place and it worked.

Thanks for the help all of you.

Post Reply