所以我想运行tracert命令,但我的问题是目标更改(tracert world1.runescape.com> tracert world140.runescape.com)
所以我的问题是,如何添加变量,使其从1一直变为140.
答案 0 :(得分:1)
尝试使用此代码:
@echo off
for /l %%# in (1,1,140) do (
echo TraceRoute for world%%#.runescape.com
echo.
Tracert world%%#.runescape.com
)
pause
如果您想将结果存储到文本文件中:
@echo off
Color 0A & Mode con cols=80 lines=3
Set LogFile=Traceroute.txt
If Exist %LogFile% Del %LogFile%
for /l %%# in (1,1,140) do (
echo TraceRoute for world%%#.runescape.com
Cls
Title Tracert world%%#.runescape.com
echo(
echo Please Wait... TraceRoute to world%%#.runescape.com in progress...
Tracert world%%#.runescape.com >> %LogFile%
)
pause
答案 1 :(得分:0)
因此,您希望继续使用tracert 140次。此代码可能会有所帮助,但它一直持续到您关闭批处理文件为止。祝你好运!!!
Sub keepFirstThreeDuplicates()
Dim workingRow As Integer
Dim currentDup As String
Dim dupCounter As Integer
Dim wsheet As Worksheet
'change this to your tab name
Set wsheet = ThisWorkbook.Sheets("Sheet1")
'loop through every row just guessing that your data starts at row 1 (A1) and goes to 50000 (A50000)
For workingRow = 1 To 50000
If workingRow = 1 Then 'we are at the first row, so grab the value and set dupCounter to 1
currentDup = wsheet.Cells(workingRow, 1).Value 'Assuming column 1, so this is Cell A1
dupCounter = 1
ElseIf currentDup = wsheet.Cells(workingRow, 1).Value Then 'we have another duplicate
If dupCounter = 3 Then 'We already have three duplicates, so delete the row, and set the row back one (because we deleted the row)
wsheet.Rows(workingRow).Delete
workingRow = workingRow - 1
Else
dupCounter = dupCounter + 1
End If
Else 'We are at a new value, so grab the value and set dupCounter to 1
currentDup = wsheet.Cells(workingRow, 1).Value
dupCounter = 1
End If
'exit the for loop if we hit a blank
If currentDup = "" Then Exit For
Next workingRow
End Sub
执行代码后,将批处理文件另存为tracert.bat并将其打开。它将一直持续到你关闭窗口。享受并请喜欢!!!