怎样实现BAT与VBS交互

2024-11-29 06:34:21
推荐回答(2个)
回答1:

看不懂可以密我bat设置a=1将a传递给vbs,加1后赋值给b将b赋值给bat,加1后赋值给c结果是a等于1,b等于2,c等于3,下面这个例子最好放在D盘根目录下运行,呵呵,代码如下:@echo off
setlocal enabledelayedexpansion
set a=1
set c=%1
if %errorlevel% neq 0 (
echo a=%a%
echo.
for /f "delims=" %%i in ('dir /b /s %0') do set d=%%i
echo b=%a%+1 >> a.vbs
for /f "delims=" %%i in ("msgbox "b^=" & b") do echo %%i >> a.vbs
for /f "delims=" %%i in ("createobject("wscript.shell").run("cmd.exe /c !d!^,"& b+1 &"")") do echo %%i >> a.vbs
a.vbs & del a.vbs
exit
) else (
echo a=%a%
echo c=%c%
)
pause

回答2:

只有所有的变量都写如文本,在从文本里提取