Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 什么@如果(@CodeSection==@Batch)@then";代表:_Batch File - Fatal编程技术网

Batch file 什么@如果(@CodeSection==@Batch)@then";代表:

Batch file 什么@如果(@CodeSection==@Batch)@then";代表:,batch-file,Batch File,嘿,我想知道这个表达式在批处理中代表什么,我试图做一个uac旁路,我需要向cmd窗口发送击键,我看到一篇文章,其中使用了这个表达式的批处理代码,我不知道函数是什么,如果有人能解释我,我将不胜感激 以下是代码来源: @如果(@code节==@Batch)@那么 @回音 rem使用%SendKeys%将按键发送到键盘缓冲区 set SendKeys=CScript//nologo//E:JScript“%~F0” rem在同一窗口中启动其他程序 启动“”/B cmd %SendKeys%“回显关闭{

嘿,我想知道这个表达式在批处理中代表什么,我试图做一个uac旁路,我需要向cmd窗口发送击键,我看到一篇文章,其中使用了这个表达式的批处理代码,我不知道函数是什么,如果有人能解释我,我将不胜感激

以下是代码来源:

@如果(@code节==@Batch)@那么
@回音
rem使用%SendKeys%将按键发送到键盘缓冲区
set SendKeys=CScript//nologo//E:JScript“%~F0”
rem在同一窗口中启动其他程序
启动“”/B cmd
%SendKeys%“回显关闭{ENTER}”
set/P“=等待并发送命令:“NUL
%SendKeys%“回音你好,世界!{ENTER}”
设置/P“=等待并发送向上箭头键:[”NUL
%SendKeys%“{UP}”
设置/P“=]等待并发送回车键:“NUL
%SendKeys%“{ENTER}”
%SendKeys%“退出{ENTER}”
后藤:EOF
@结束
//JScript部分
var WshShell=WScript.CreateObject(“WScript.Shell”);
SendKeys(WScript.Arguments(0));

它不是-它是Jscript

如果此文件作为Jscript运行,则由于
If
将失败,因此
@then
@end
之间的部分将不会执行,而Jscript部分将被执行


如果它以批处理文件的形式运行,那么由于
(@codessection
不等于
@batch)
,因此将不会执行
@then
命令,因此该行后面的命令将被执行,最终到达
goto:eof
,它将覆盖文件的其余部分。

这是一种混合批处理jscript。批处理文件可以与文章混合编写,甚至与文章没有任何错误,但由于这是您的第一次,而且您还没有这样做,请阅读,然后阅读。解释出现在您链接的相同答案中,在“有关此解决方案的进一步解释,请参阅:”。注释中也扩展了解释……对于没有在注释中明确声明这是他们意图的程序员来说,应该有一个特别的地狱。我愿意打赌这类事情在浪费中间程序员时间的事情列表中得分很高。当然,微软要为这些废话承担部分责任*尼克斯系统很久以前就把这类事情标准化了。
@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));