如何从批处理脚本中正确执行? [英] How to have the correct execution from a batch script?

查看:90
本文介绍了如何从批处理脚本中正确执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的蝙蝠脚本:

@echo off
cls

for /F "tokens=*" %%a in (Keys.txt) do (
  RoundKey.exe "%%a"


)

文件Keys.txt在每一行中都包含一个我需要更改以执行RooundKey.exe程序的密钥.该程序仅需输入一个键即可.我总共有10000 keys,因此很难一一更改.在命令行中执行RoundKey.exe程序时,其输出为:

The file Keys.txt contains in each line a key that I need to change executing the RooundKey.exe program. This program take in parameter just one key. I have at total 10000 keys, so it is very hard to change them one by one. The output from the RoundKey.exe program while executing it in the command line is:

这是命令行:

RoundKey.exe  "E0 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"

这是输出:

00: E0 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
01: 36 AA 74 FD 32 AF 72 FA 3A A6 78 F1 36 AB 76 FE
02: 56 92 CF F8 64 3D BD 02 5E 9B C5 F3 68 30 B3 0D
03: 56 FF 18 BD 32 C2 A5 BF 6C 59 60 4C 04 69 D3 41
04: A7 99 9B 4F 95 5B 3E F0 F9 02 5E BC FD 6B 8D FD
05: C8 C4 CF 1B 5D 9F F1 EB A4 9D AF 57 59 F6 22 AA
06: AA 57 63 D0 F7 C8 92 3B 53 55 3D 6C 0A A3 1F C6
07: E0 97 D7 B7 17 5F 45 8C 44 0A 78 E0 4E A9 67 26
08: B3 12 20 98 A4 4D 65 14 E0 47 1D F4 AE EE 7A D2
09: 80 C8 95 7C 24 85 F0 68 C4 C2 ED 9C 6A 2C 97 4E
10: C7 40 BA 7E E3 C5 4A 16 27 07 A7 8A 4D 2B 30 C4

我放了这个批处理脚本来帮助实现这一点,假设我的keys.txt文件中有:

I put this batch script to help in doing that, Let's suppose that I have in my keys.txt file:

e0 01 02 21 03 05 06 67 08 88 0a 0b ea 0d ac 08
00 45 22 03 64 05 56 07 98 ea 1a 56 1f 1d 78 1a
50 01 02 53 04 05 78 08 10 4c 0a 89 cb 0d a6 cb
......

因此,当我执行bash脚本时,我只得到第一个键的结果,然后将其休眠.我两次输入CTRL + C,结果得到第二个键,第三个键也一样:

so when I execute my bash script, I get just the result of the first key, then it is sleeped. I put CTRL+C IT two times, I got as a result the second key, the same for the third key:

   00: E0 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
01: 36 AA 74 FD 32 AF 72 FA 3A A6 78 F1 36 AB 76 FE
02: 56 92 CF F8 64 3D BD 02 5E 9B C5 F3 68 30 B3 0D
03: 56 FF 18 BD 32 C2 A5 BF 6C 59 60 4C 04 69 D3 41
04: A7 99 9B 4F 95 5B 3E F0 F9 02 5E BC FD 6B 8D FD
05: C8 C4 CF 1B 5D 9F F1 EB A4 9D AF 57 59 F6 22 AA
06: AA 57 63 D0 F7 C8 92 3B 53 55 3D 6C 0A A3 1F C6
07: E0 97 D7 B7 17 5F 45 8C 44 0A 78 E0 4E A9 67 26
08: B3 12 20 98 A4 4D 65 14 E0 47 1D F4 AE EE 7A D2
09: 80 C8 95 7C 24 85 F0 68 C4 C2 ED 9C 6A 2C 97 4E
10: C7 40 BA 7E E3 C5 4A 16 27 07 A7 8A 4D 2B 30 C4
^CTerminate batch job (Y/N)?
^C00: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
01: D6 AA 74 FD D2 AF 72 FA DA A6 78 F1 D6 AB 76 FE
02: B6 92 CF 0B 64 3D BD F1 BE 9B C5 00 68 30 B3 FE
03: B6 FF 74 4E D2 C2 C9 BF 6C 59 0C BF 04 69 BF 41
04: 47 F7 F7 BC 95 35 3E 03 F9 6C 32 BC FD 05 8D FD
05: 3C AA A3 E8 A9 9F 9D EB 50 F3 AF 57 AD F6 22 AA
06: 5E 39 0F 7D F7 A6 92 96 A7 55 3D C1 0A A3 1F 6B
07: 14 F9 70 1A E3 5F E2 8C 44 0A DF 4D 4E A9 C0 26
08: 47 43 87 35 A4 1C 65 B9 E0 16 BA F4 AE BF 7A D2
09: 54 99 32 D1 F0 85 57 68 10 93 ED 9C BE 2C 97 4E
10: 13 11 1D 7F E3 94 4A 17 F3 07 A7 8B 4D 2B 30 C5
^CTerminate batch job (Y/N)?
^C00: 50 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
01: 86 AA 74 FD 82 AF 72 FA 8A A6 78 F1 86 AB 76 FE
02: E6 92 CF B9 64 3D BD 43 EE 9B C5 B2 68 30 B3 4C
03: E6 FF E6 FC 82 C2 5B BF 6C 59 9E 0D 04 69 2D 41
04: 17 27 65 0E 95 E5 3E B1 F9 BC A0 BC FD D5 8D FD
05: 04 7A 31 5A 91 9F 0F EB 68 23 AF 57 95 F6 22 AA
06: 66 E9 9D 70 F7 76 92 9B 9F 55 3D CC 0A A3 1F 66
07: 2C 29 AE 17 DB 5F 3C 8C 44 0A 01 40 4E A9 1E 26
08: 7F 5B 59 38 A4 04 65 B4 E0 0E 64 F4 AE A7 7A D2
09: 38 81 EC DC 9C 85 89 68 7C 8B ED 9C D2 2C 97 4E
10: 7F 09 C3 69 E3 8C 4A 01 9F 07 A7 9D 4D 2B 30 D3
^CTerminate batch job (Y/N)?
^C'n' is not recognized as an internal or external command,
operable program or batch file.

那我该如何解决这个问题?

So How could I please resolve this problem?

推荐答案

似乎,RoundKey的默认退出"是Ctrl-C(没有其他键起作用).

Seems, the default "Exit" of RoundKey is a Ctrl-C (no other key works).

但是您可以start /b程序,并在短暂的等待时间后强行杀死它:

But you can start /b the program and forcefully kill it after a short wait time:

@echo off
for /f "tokens=*" %%a in (keys.txt) do (
  echo ----------
  start /b "" RoundKey.exe "%%a"
  timeout -t 1 >nul
  taskkill /f /im:RoundKey.exe >nul
)

不确定,您需要哪个输出.如果只需要最后一行:

Not sure, which output you need. If you need the last line(s) only:

@echo off
setlocal enabledelayedexpansion
for /f "tokens=*" %%a in (keys.txt) do (
  for /f "tokens=*" %%b in ('
       start /b "" roundkey.exe "%%a" ^& timeout 1 ^>nul ^& taskkill /f /im:RoundKey.exe ^>nul
     ') do set "key=%%b"
  echo !key! (Input was: %%a)
)

这篇关于如何从批处理脚本中正确执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆