Board logo

标题: [问题求助] VBS获取用户输入作为变量并传递给另一个EXE程序 [打印本页]

作者: mnokoko    时间: 2023-12-18 10:49     标题: VBS获取用户输入作为变量并传递给另一个EXE程序

具体如下:
用户输入字串符,比如1234567890
把这串数字传递给gogo.exe程序

dim fname
fname=InputBox("Enter your name:")


剩下的我就不懂了

感谢帮助!
作者: czjt1234    时间: 2023-12-18 11:04

  1. dim fname, oWshShell
  2. Set oWshShell = CreateObject("WScript.Shell")
  3. fname = InputBox("Enter your name:")
  4. fname = """" & fname & """"
  5. oWshShell.Run "gogo.exe " & fname
复制代码
如果gogo.exe能处理命令行参数
作者: ShowCode    时间: 2023-12-18 11:04

回复 1# mnokoko
  1. Dim fname
  2. fname = InputBox("Enter your name:")
  3. Set WshShell = WScript.CreateObject("WScript.Shell")
  4. WshShell.Run "C:\Test\gogo.exe " & fname
复制代码

作者: mnokoko    时间: 2023-12-18 11:31

回复 2# czjt1234


    如果用下面这种方式传递呢?
oWshShell.sendkeys 用户输入
oWshShell.sendkeys "{enter}"
wscript.quit
作者: mnokoko    时间: 2023-12-18 11:31

回复 3# ShowCode

接收不到参数,如果用下面这种呢?
oWshShell.sendkeys fname
oWshShell.sendkeys "{enter}"
wscript.quit
作者: mnokoko    时间: 2023-12-18 11:35

回复 5# mnokoko


set wshshell=CreateObject("Wscript.shell")
wshshell.run "c:\test\gogo.exe"
wscript.sleep 1000
wshshell.sendkeys "1234567890"
wshshell.sendkeys "{enter}"
wscript.quit

用这种方式可以,但是wshshell.sendkeys "1234567890"这句变量怎么写?
作者: czjt1234    时间: 2023-12-18 13:09

fname = InputBox("Enter your name:")
set wshshell = CreateObject("Wscript.shell")
wshshell.run "c:\test\gogo.exe"
wscript.sleep 1000
wshshell.sendkeys fname
wshshell.sendkeys "{enter}"
wscript.quit




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