我有一个.exe,需要3个整数作为输入.例如:
myCode.exe < input.txt
Run Code Online (Sandbox Code Playgroud)
在input.txt中:
2
3
8
Run Code Online (Sandbox Code Playgroud)
现在我想将命令放在批处理文件中.我该如何编写批处理文件?(这里我想在批处理文件中传递3个固定整数)
谢谢!
您好我第一次使用BATCH脚本,我得到的硬盘大小如下:
wmic diskdrive get size
Run Code Online (Sandbox Code Playgroud)
哪个工作正常,但我想将此值存储到变量中供以后使用,例如使用ECHO显示值.
我不确定如何将上述命令的输出设置为变量.我去了:
SET hddbytes=wmic diskdrive get size
Run Code Online (Sandbox Code Playgroud)
但这只是将变量设置为上面的文本字符串而不是输出.
任务是启动程序使用wmic process call create "c:\folder\app.exe"并app.exe访问它自己的支持文件app.exe home folder tree.
下面的批处理脚本说明了WMIC以静默方式更改工作目录的问题,因此无法找到支持文件.
此脚本创建第二个批处理文件one.bat,该url.txt文件只是从同一文件夹中键入文件,以显示www.google.com在控制台上.
当wmic用于创建进程时,wmic会静默地更改工作目录,以便one.bat找不到,如果我指定完整路径,d:\abc\one.bat那么one.bat它将启动,但它无法找到要url.txt在其自己的文件夹中调用的文件.
如果我将WMIC.EXE文件复制到同一文件夹,它会以相同的方式失败.
@echo off
set "folder=d:\abc"
cd /d "%folder%"
(
echo.@echo off
echo.type url.txt
echo.pause
)>one.bat
(
echo.@echo off
echo.www.google.com
)>url.txt
echo this will work to launch the one.bat but the working directory is wrong and the file can't be found
wmic process call create "%folder%\one.bat"
pause
echo …Run Code Online (Sandbox Code Playgroud) 我有这个小config.json:
{
"version":"0.2.2",
"test":true
}
Run Code Online (Sandbox Code Playgroud)
我想读取这个文件并在窗口命令行中设置与json文件中的键和值相对应的变量,可能类似于这个伪代码:
for /f %%A in (config.json) do (
SET key = value
)
echo %VERSION%
echo %TEST%
Run Code Online (Sandbox Code Playgroud)
我该怎么办?
如何使用Batch删除文件的第一行?
我真的需要帮助......我已经尝试了一切,但它没有用.:(我试过这个:
@echo off
Type test.txt | findstr /I /V /C:"So, lets remove this line" >>Test2.txt
exit
Run Code Online (Sandbox Code Playgroud) 我的"if condition"如下所示,
if (expression1 || expression2) {
// do something
} else {
// do something
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,如果expression1得到满足,那么代码流将转到else part或expression2得到检查,然后转到else部分.
我想帮助创建一个自动BAT脚本,以便在因特网中断时重新连接我的Cisco VPN客户端会话.
有两个命令行:command 1连接和command 2断开连接.
要监视连接,我想使用ICMP(Like 5 failed pings),如果使用VPN,则继续转发数据.如果不使用command 2断开VPN会话并尝试重新连接.
如果可能的话,我希望它循环,这样每次WAN Link断开时它都会自动重新连接.
命令1:客户端程序位于: C:\Program Files (x86)\Cisco Systems\VPN
start vpnclient connect rcx user TESTE pwd TESTE stdin
Run Code Online (Sandbox Code Playgroud)
命令2:客户端程序位于:C:\Program Files (x86)\Cisco Systems\VPN
vpnclient disconnect
Run Code Online (Sandbox Code Playgroud)
我做了很多尝试但没有成功.
我正在编写一个批处理脚本来从文件中读取.该文件包含诸如token = value之类的行.我有代码来解析文件的每一行,它存储在%% i中.以下代码尝试提取令牌的值:
请注意,此脚本正在使用延迟扩展,如评论中所述.
for /f "tokens=1* delims==" %%a in ("%%i") do (
if "%%a"=="password" ( set password=%%b )
)
Run Code Online (Sandbox Code Playgroud)
如果令牌密码的值包含"!",那么"!" 被跳过,只有其余的字符串存储在变量密码中.例如,如果该行是:
密码=测试!
然后变量密码=测试.我试图以各种方式更改输入文件,批处理脚本读取除"!"之外的所有内容.我用过:
密码=测试%!
密码=测试%!
一切都跳过"!".知道如何用"!"读取字符串 变成一个变量?
防火墙已关闭,但仍然无法在ftp上执行put commend
ftp>cd /web
250 CWM command successful
ftp>binary
200 Type set to I
ftp>put C:\sample.xml
200 PORT command successful
425 Unable to build data connection: No route to host
Run Code Online (Sandbox Code Playgroud) batch-file ×8
windows ×3
cmd ×2
cisco ×1
command ×1
command-line ×1
findstr ×1
ftp ×1
if-statement ×1
objective-c ×1
text-files ×1
wmic ×1