![]() |
I need help with a batch file
Hi,
I'm trying to create a batch file to run a tracert and out the results to a file to see if its going through a different route. How do I do it and can I loop it say 100 times? I know this may sound dodgy but I'm trying to prove to our companys IT suppliers that we are using two different proxies and one is being used random and blocking our users from accessing our site. if we use a user friendly url it causes problems but if you use the server name directly then it does not cause a problem. please any help much appreciate. |
Re: I need help with a batch file
To output tracert to a file it's just as simple as adding > XXXX.txt to the end, if you want it to append to a file it's >> XXXX.txt
For example Code:
tracert bbc.co.uk > trace.txt If you repeated it with Code:
tracert bbc.co.uk >> trace.txt Just loop that in a batch file 100 time (there's a few different methods) and you should have you file. |
Re: I need help with a batch file
A tracert will not show 2 different web proxies though?
|
Re: I need help with a batch file
yeah but maybe its a firewall somewhere and it can give me some IP addresses I could chekc with the support team.
Thanks Kymmy how do I loop that. ---------- Post added at 12:06 ---------- Previous post was at 12:01 ---------- Graham what do you suggest I try to trace the connection my pc to my server? |
Re: I need help with a batch file
Set a variable, increment it by one, check within a loop if it gets to 100 if so then point past the loop ;)
Not done batch files for years but something like Code:
@echo off set VAR to 1, loop start, if var is greater than 100 then goto end, tracert to file, add 1 to VAR, goto loop, end |
Re: I need help with a batch file
hmm that code seems logical but it does not seem to be doing anything. If I run just the tracert by itself it writes the results to the file but if I place that in the loop it does not create the file and does not append anything to it.
Any ideas? I really need to get some good reference on batch files. They can be really useful. ---------- Post added at 12:31 ---------- Previous post was at 12:31 ---------- how can I append the VAR value to the file as well ? |
Re: I need help with a batch file
replace trace.txt with %%var (each % represents a digit)
---------- Post added at 12:54 ---------- Previous post was at 12:50 ---------- as I said though it has been a long, long, long time since I did a batch file It seems to have a problem with the IF statement, I'm sure that one of the usual programmers will be round shortly |
Re: I need help with a batch file
Since the loop appends to a file it expects to find it existing. Try creating an empty file with that name before running the bat.
|
Re: I need help with a batch file
Hi David,
I tried that and still no luck. This is my batch file. Does it not need some sort of pause to process it? Code:
@echo off |
Re: I need help with a batch file
With vbscript and batch:
vbscript: Code:
dim i Code:
tracert bbc.co.uk >> trace.txt ---------- Post added at 14:40 ---------- Previous post was at 14:36 ---------- Want to make it silent as well? Just tells you when it's done...: VBscript: Code:
dim i |
Re: I need help with a batch file
Am I'm right in thinking I need to run the vbScript? how do I create the vbscript file?
Sorry I'm more of a pl/sql coder. |
Re: I need help with a batch file
create the VBScript file using notepad (or similar) and save it as '<filename>.vbs'.
You should then just be able to double-click it to run it. |
Re: I need help with a batch file
thanks I've run that and counted the entrys and they is no way there is 100 entrys in the txt file.
Any ideas why there would be some missing? |
Re: I need help with a batch file
did you give it enough time tio run fully?
|
Re: I need help with a batch file
I left it with the 15sec delay but I just counted 12 entries. I did take around 20mins to run before I got the msgbox saying it was complete.
|
All times are GMT +1. The time now is 06:58. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
All Posts and Content are © Cable Forum