怎样实现BAT与VBS交互
如题,举个例子,在BAT中,设置变量A=20,传递给VBS的变量B,VBS又返回一个值给BAT的变量C,该怎么写?...
如题,举个例子,在BAT中,设置变量A=20,传递给VBS的变量B,VBS又返回一个值给BAT的变量C,该怎么写?
展开
2个回答
2013-03-28
展开全部
看不懂可以密我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
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询