“@if (@CodeSection == @Batch) @then”代表什么:

1 batch-file

嘿,我想知道批处理中的这个表达式代表什么,我试图绕过 uac,我需要将击键发送到 cmd 窗口,我看到一篇文章使用带有这个表达式的批处理代码,我不知道什么是如果有人可以解释我的功能,我将不胜感激!

继承代码:使用批处理文件按键盘键

@if (@CodeSection == @Batch) @then


@echo off

rem Use %SendKeys% to send keys to the keyboard buffer
set SendKeys=CScript //nologo //E:JScript "%~F0"

rem Start the other program in the same Window
start "" /B cmd

%SendKeys% "echo off{ENTER}"

set /P "=Wait and send a command: " < NUL
ping -n 5 -w 1 127.0.0.1 > NUL
%SendKeys% "echo Hello, world!{ENTER}"

set /P "=Wait and send an Up Arrow key: [" < NUL
ping -n 5 -w 1 127.0.0.1 > NUL
%SendKeys% "{UP}"

set /P "=] Wait and send an Enter key:" < NUL
ping -n 5 -w 1 127.0.0.1 > NUL
%SendKeys% "{ENTER}"

%SendKeys% "exit{ENTER}"

goto :EOF


@end


// JScript section

var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));
Run Code Online (Sandbox Code Playgroud)

Mag*_*goo 5

它不是——它是 Jscript。

如果这个文件作为Jscript运行,那么由于会失败,那么和if之间的部分将不会被执行,而Jscript部分将被执行。@then@end

如果它作为批处理文件运行,则由于(@CodeSection不等于@Batch),该命令@then不会被执行,因此该行后面的命令将被执行,最终到达跳过goto :eof文件其余部分的位置。

  • 对于那些没有在评论中明确声明这是他们的意图的程序员来说,应该有一个特殊的地狱。我愿意打赌,这种事情在浪费菜鸟到中级编码员时间的事情列表中得分很高。当然,微软对这种垃圾事件负有部分责任。*nix 系统很久以前就标准化了这类事情。 (2认同)

归档时间:

查看次数:

2137 次

最近记录:

7 年,9 月 前