Board logo

标题: [其他] 【已解决】批处理如何通过for命令设置多个变量? [打印本页]

作者: hbb    时间: 2014-6-7 20:56     标题: 【已解决】批处理如何通过for命令设置多个变量?

本帖最后由 hbb 于 2014-6-7 21:35 编辑

请问以下批处理脚本的for命令得出的三个值如何通过set分别赋值给ip port password变量,谢谢!
  1. @echo off
  2. echo Wsh.Echo InputBox("请输入IP地址:","提示","")>"%temp%\tmp.vbs"
  3. echo Wsh.Echo InputBox("请输入端口号:","提示","")>>"%temp%\tmp.vbs"
  4. echo Wsh.Echo InputBox("请输入密码:","提示","")>>"%temp%\tmp.vbs"
  5. for /f %%a in ('cscript "%temp%\tmp.vbs" //nologo //e:vbscript') do set "ip=%%a" set "port=%%a" set "password=%%a"
  6. del /q "%temp%\tmp.vbs"
  7. pause
复制代码

作者: apang    时间: 2014-6-7 21:24

  1. @echo off
  2. (
  3.     echo Wsh.Echo "ip="^&InputBox("请输入IP地址:","提示",""^)
  4.     echo Wsh.Echo "port="^&InputBox("请输入端口号:","提示",""^)
  5.     echo Wsh.Echo "password="^&InputBox("请输入密码:","提示",""^)
  6. )>"%temp%\tmp.vbs"
  7. for /f "delims=" %%a in ('cscript "%temp%\tmp.vbs" //nologo //e:vbs') do (
  8.     echo,set "%%a"
  9. )
  10. del /q "%temp%\tmp.vbs"
  11. pause
复制代码

作者: hbb    时间: 2014-6-7 21:35

回复 2# apang


    非常感谢,问题解决!




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2