从批量传输变量VBScript文件返回空 [英] Transferring variable from batch to VBScript file returns empty

查看:272
本文介绍了从批量传输变量VBScript文件返回空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想给一个变量从打开Telnet会话,当telnet会话是开放运行的VB脚本的批处理文件传输:

I am trying to transfer a variable from a batch file that opens a telnet session to a VB script that runs when the telnet session is open:

echo Welcome to Xyplex Server Port Reset

set /p whichXplex= Which Xyplex server is your device connected too: 1 or 2 ?
echo.
set /p "whichPort= Which port do you want to reset:" 
echo.

REM Pass the variable portnumber to script 
cscript.exe //NoLogo loginInXyplex.vbs /portname:"%whichPort%"

.....打开一个telnet会话和运行脚本

.....open a telnet session and run the script

脚本telnet会话,在那里我尝试打印从批处理文件传递的变量过程中运行:

The script runs during the telnet session, where I try to print the variable passed from the batch file:

set OBJECT=WScript.CreateObject("WScript.Shell")
OBJECT.SendKeys"{ENTER}"
OBJECT.SendKeys "username{ENTER}"
WScript.sleep 50
......etc

'Get the port number sent from batch file
port = WScript.Arguments.Named("portname")


    OBJECT.SendKeys  "Port number selected is: " & port

但输出始终是空白的:

But the output is always blank:

选择的端口号码是:

哪里是我的code中的错误呢?

Where is the mistake in my code?

推荐答案

这可以帮助其他新手到VB脚本:
发行iscalling在批处理文件中两个脚本,调用它首先块当excution流,从而没有被发送到Telnet会话期间运行第二个脚本。
使用命令

This may help another newbie to vb scripting: Issue iscalling two scripts in batch file, when calling the first it blocks the excution flow so nothing is sent to the second script running during the telnet session. Using command

启动/ B的cscript // NOLOGO ...............

将运行parrell第一个脚本随后命令(所以我最终修改设计,我的情况,实际上创造了更多的问题)。

will run the first script in parrell with subsequent commands (which actually created more issues in my situation so I ended up modifying the design).

这篇关于从批量传输变量VBScript文件返回空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆