批处理的变量调用问题
@Echo off
REM 酷泥巴制作
mode con: cols=30 lines=8
Color 0A
Title 下载DirectX9.0c by酷泥巴
CD DX9.0c
cls
echo 正在检测当前系统环境…
IF EXIST C:\WINDOWS\system32\D3DX9_39.dll (
ECHO DirectX9.0c已经安装
pause
Exit
) ELSE (
set Link=thunder://QUFodHRwOi8vcGF0Y2g3LmFsaTIxMy5uZXQvbmV3cGF0Y2gyNi9kaXJlY3R4OTA5MDgucmFyWlo=
cd.>tmp.vbs
for /f "usebackq skip=21 tokens=*" %%a in (%0) do @echo %%a>>tmp.vbs
tmp.vbs&del tmp.vbs /q
goto :eof
Exit
)
Rem 以下为VbScript脚本
set ThunderAgent = CreateObject("ThunderAgent.Agent.1")
Call ThunderAgent.AddTask("%Link%","还是俺的blog","c:\a\b\c\","","",1,0,5)
Call ThunderAgent.CommitTasks()
===========================================
这是一个调用迅雷下载文件的批处理。
但是运行后,迅雷的地址栏显示为%Link%,不知道该如何改正?
[解决办法]
也许
Call ThunderAgent.AddTask(%Link%,"还是俺的blog","c:\a\b\c\","","",1,0,5)
[解决办法]
VBS里面不能直接用%LINK%去引用环境变量,应该这样:
Set shell = CreateObject( "WScript.Shell" )
link=shell.ExpandEnvironmentStrings("%LINK%")
[解决办法]
原来要这样,比较简单:
@Echo off
REM 酷泥巴制作
mode con: cols=30 lines=8
Color 0A
Title 下载DirectX9.0c by酷泥巴
CD DX9.0c
cls
echo 正在检测当前系统环境…
IF EXIST C:\WINDOWS\system32\D3DX9_39.dll (
ECHO DirectX9.0c已经安装
pause
Exit
) ELSE (
set Link=thunder://QUFodHRwOi8vcGF0Y2g3LmFsaTIxMy5uZXQvbmV3cGF0Y2gyNi9kaXJlY3R4OTA5MDgucmFyWlo=
cd.>tmp.vbs
for /f "usebackq skip=23 tokens=1,* delims=_" %%a in (%0) do (
if "%%b" neq "" (@echo %%a%link%%%b>>tmp.vbs) else @echo %%a>>tmp.vbs
)
tmp.vbs&del tmp.vbs /q
goto :eof
Exit
)
Rem 以下为VbScript脚本
set ThunderAgent = CreateObject("ThunderAgent.Agent.1")
Call ThunderAgent.AddTask("_","还是俺的blog","c:\a\b\c\","","",1,0,5)
Call ThunderAgent.CommitTasks()
[解决办法]