How can I send a command to another VBScript? [duplicate]

僤鯓⒐⒋嵵緔 提交于 2021-01-20 13:58:11

问题


I need help rendering input through 2 different VBScripts. Here's my code, but I need a way of rendering the input of A.vbs into B.vbs, here's my code:

Option Explicit
Dim Shell
Set Shell = CreateObject("WScript.Shell")
Speed = InputBox("How long do you have to wait between clicks, in seconds?", "")
Wait = InputBox("How long until this script runs?", "")
msgbox("You have " & Wait & " seconds until this script runs.")
WScript.Sleep (Wait*1000)
Shell.Run "B.vbs"

回答1:


You can use Environment Variables:

' Create WSH Shell object
Dim objWshShell
Set objWshShell = CreateObject("WScript.Shell")

' Get the Environment
Dim objEnvironment
Set objEnvironment = objWshShell.Environment("System")

' Write to variable
objEnvironment("Speed") = Speed

' Read from variable
MsgBox objEnvironment("Speed")

You will want to write to the environment variable(s) in your A.vbs script and read from the variable(s) in your B.vbs script.



来源:https://stackoverflow.com/questions/65587978/how-can-i-send-a-command-to-another-vbscript

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!