创建的批处理文件:
@Echo off&SetLocal EnableExtensions EnableDelayedExpansion
set execute counter=0
Set "Pass=45454545854545854254545454"
Echo Password is:%Pass%
start "" https://xxx.xxx/xxx/%pass%
:test
set "Pass=%Pass%"
set "Pass=!Pass:~1,-1!
echo Password is :%Pass%
start "" https://xxx.xxx/xxx/%pass%
goto test
要求:我想用给定的%pass%
字符串打开URL,在每个循环中,我想从字符串中去除最后一个字符,直到URL保留一个字符为止。
示例:
1st url : https://xxx.xxx/xxx/45454545854545854254545454
2nd url : https://xxx.xxx/xxx/4545454585454585425454545
.......
last url : https://xxx.xxx/xxx/4
答案 0 :(得分:4)
这是一个可能的解决方案:
@echo off
Setlocal EnableExtensions EnableDelayedExpansion
set "execute counter=0"
Set "Pass=45454545854545854254545454"
Echo Password is: %Pass%
start "" https://xxx.xxx/xxx/%pass%
goto test
:test
set "Pass=!Pass:~0,-1!"
if defined Pass (
echo Password is: !Pass!
start "" https://xxx.xxx/xxx/!pass!
rem pause
rem Add pause not to overload your computer!
goto test
) else (
echo No more characters to strip!
pause
exit /b
)
为了避免出现任何奇怪的行为,我在execute counter
中引用了set
变量。在主代码末尾添加了goto test
(不是真正需要的)。
答案 1 :(得分:4)
您可以用更少的代码来完成此操作。
@echo off
Set "Pass=45454545854545854254545454"
:loop
echo https://xxx.xxx/xxx/%pass%
set "pass=%pass:~0,-1%"
IF DEFINED pass GOTO loop