Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I hope this clarification is a lot better than what it was previously.

So, I am trying to create a batch file that will do the following.. I have the ultimate goal at the bottom, but right now I am ONLY stuck at getting one batch file to launch multiple command prompts. I am just seeing if this can be done, or if I would need to make a batch file for each job, and then make a master batch file that would tell each individual what to do.

1. Run on startup(which I know how).
2. Ping <hostname>
3. Ping <hostname's>
4. Traceroute to Hostname and Hostname's IP every 5 minutes.
5. Create daily logs of all results.

Unfortunately, I am familiar with Batch Files only, so if anyone has any better suggestions I would love to hear them.

Here are my computer stats:

Host: Windows 7 Ultimate 64 bit
Vmware Player 7 Pro Free(Non-Commercial Use)
Vmware Guest: Windows XP Pro SP3

Only reason I am using XP is because I am having conflict video driver issues with the graphics card.. It is running on a driver that is designed for XP only, so if I am not careful I will get a BSOD on my Win & host.

If I could even acheive the same function in CentOS that would help out a lot as well(seeing that I can just do it CLI).

---------------

Anyways, I have the following portion:

-------START-------
@echo off
ping -t <mymailserver.com>
call C:\WINDOWS\System32\cmd.exe /K "ping -t 192.168.255.255"
-------END---------

I want each command to open in its own window. Like the ping <host> in one window. Ping <hostname ip=""> in another, and every 5 minutes the traceroute will pop up and run in a 3rd command prompt window.

I also tried(commands below) but I can't get a new window to pop up.

start cmd "ping -t 192.168.255.255"
start cmd /K "ping -t 192.168.255.255"
cmd "ping -t 192.168.255.255"
cmd /K "ping -t 192.168.255.255"

I've read numerous forums, syntax, and I am not able to find the way to do it.


Moved from "answer":
Well I'm not that far down the project yet, but if that is case, wouldn't it involved having to create separate batch files for each job? since I want the pings to stay continuous and the traceroute every 5 minutes?

At the moment, I am fighting it trying to get it to open a second command prompt window to run the second continuous ping... That is my current issue.

I've read all the comments/solutions available, and Powershell I will look into it.

Here's a little backstory(I will keep to the point). I have an end user that is complaining that they are losing physical connection to our Domain/Mail Hosting Server. They are in the Mid-U.S, and I am in AL. Each time they report the issue, I search the mail logs, error logs on said server and found no physical, logical, or down time on the server. Also we have other end users as well that do not report any issues at the same time. I have this computer off the complete network(remote access only ability) so I can't even get out to the location and no one is near said server. I am hoping that to get this set up so that the next time this particular EU reports said issue, I can pull the history logs on the date/time in question to compare my connection status with their timeframe.


The ultimate goal of this is the following:

One Command Prompt using the command: Ping -t 220.54.19.4

One Command Prompt using the command: Ping -t mail.domainishere.com

One Command Prompt using the command: tracert 220.54.19.4

One Command Prompt using the command: tracert mail.domainishere.com

So in all 4 Command Prompts running simutaneous. The 2 Traceroute Command Prompts, I want to every 5 minutes so that if I CAN repeat what said end user is going through, I can see where the connection is being lost at.

At the end of the traceroutes ran, I want to send the information that was gotten from the interval into a log file so that way, I can keep a detail history in case they complain of any connection issues, I can pull the said time/date log and view what they were and compare to the issues they have.

At the end of each day, all the ping results(which I prefer them to be timestamped) to be moved to a log file to keep a detail history.
Posted
Updated 18-Jan-15 10:14am
v3
Comments
Sergey Alexandrovich Kryukov 18-Jan-15 15:06pm    
Bad idea in general: 1) using batch "programming" for anything serious; 2) do anything periodically.
Batch files is not "real" programming, it's more of the user's level. I would probably help on something related to batches, but only if it was related to programming. I don't want to waste time on helping too much of off-topic items. Why not starting to learn programming, after all?
—SA
Member 11383787 18-Jan-15 15:13pm    
Sergey,

I know the fundamentals and basics of Python, but if I am not mistaken(and I could be since I'm a beginner at it), Python(and any other programming languages) doesn't have built in ping/traceroute, so I would still need to get said language to call those commands correct?

Yes, I do like your idea don't get me wrong there. Not to mention the fact that on a side note, I would like to have the ping & traceroute timestamped at each response that shows in the window. If you have any suggestions/tutorial sites that can assist, I am more than happy to hear them out.
Member 11381998 18-Jan-15 23:30pm    
sergey,
I know the fundamentals and basics of python.....!!

How about some Windows Scheduled Tasks?
 
Share this answer
 
v2
Comments
RedDk 18-Jan-15 15:15pm    
Honestly?

This is not in anywayshapeorform an answer. Sorry
Sergey Alexandrovich Kryukov 18-Jan-15 15:21pm    
Who is or what is anywayshapeorform? Didn't you misplace your comment?

I don't consider this answer as perfect, but it is certainly related to the question. You did not read it properly yourself.
Look at this: "if anyone has any better suggestions I would love to hear them".

So, aren't you the one who voted 1 on this answer? This is totally unreasonable. If it was you, don't you want to fix it?

—SA
Sergey Alexandrovich Kryukov 18-Jan-15 15:24pm    
Usually I don't vote to just to compensate any bad vote, but, in this case, I voted 5 because at least it makes full sense.
I would first ask more on the OP's goals, first of all (I already did). The real problem is to advise anything to the one who is not a software engineer. With batch files, one won't go far...
Please see my answer.
—SA
Please see my comment to the question. I feel your position here is pretty difficult. If a software engineering is involved, it's really hard to help to not a software engineer (something I deduces from your statement "Unfortunately, I am familiar with Batch Files only").

If you rationally analyze what's wrong with batch files, the central point will probably be: the lack of any reasonably usable debugging. So, I thought that one of the closest approaches would be getting to use Microsoft Windows PowerShell instead:
http://en.wikipedia.org/wiki/Windows_PowerShell[^],
http://microsoft.com/powershell[^].

The latest version suggests not just usable, but wonderfully convenient debugger.

Still, this is close to programming and will actually give you nearly all power of .NET programming, even though in scripting setting and without the ability to build any assemblies or executable modules. But you could use some sub-set of programming model, that is, same as batch, but also with debugging, and a lot more.

As I said, anything like "every 5 minutes" sounds suspicious to me. Everything which can be understood as pull technology can be considered as evil, some wasteful and yet inefficient thing. (Please see http://en.wikipedia.org/wiki/Pull_technology[^], Application 'dashboard' for website accounts[^]).

Nevertheless, your information is by far not enough for judgement. We could discuss all your problems (not just pull) only if you give us clear idea of your ultimate goals.

—SA
 
Share this answer
 
Comments
RedDk 18-Jan-15 15:27pm    
Is this the answer to your question, Sergey?
Sergey Alexandrovich Kryukov 18-Jan-15 15:31pm    
Didn't you misplace your comment again?

This is the answer to the inquirer's question. It cannot be my answer to any of my own questions. Can you see it?
I asked you some questions related to your comment to Solution 1. I will appreciate if you chose to answer them, especially if you make clear what you are answering to. And of course, your own questions will be welcome.

As to your comment above, it does not look like a comprehensible question to me, by the reason I just explained.

Thank you.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900