找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 12888|回复: 6

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

[复制链接]
发表于 2023-12-18 10:49:54 | 显示全部楼层 |阅读模式
具体如下:
用户输入字串符,比如1234567890
把这串数字传递给gogo.exe程序

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


剩下的我就不懂了

感谢帮助!
发表于 2023-12-18 11:04:06 | 显示全部楼层
  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能处理命令行参数
发表于 2023-12-18 11:04:11 | 显示全部楼层
回复 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
复制代码
 楼主| 发表于 2023-12-18 11:31:08 | 显示全部楼层
回复 2# czjt1234


    如果用下面这种方式传递呢?
oWshShell.sendkeys 用户输入
oWshShell.sendkeys "{enter}"
wscript.quit
 楼主| 发表于 2023-12-18 11:31:57 | 显示全部楼层
回复 3# ShowCode

接收不到参数,如果用下面这种呢?
oWshShell.sendkeys fname
oWshShell.sendkeys "{enter}"
wscript.quit
 楼主| 发表于 2023-12-18 11:35:16 | 显示全部楼层
回复 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"这句变量怎么写?
发表于 2023-12-18 13:09:51 | 显示全部楼层
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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-16 23:22 , Processed in 0.018201 second(s), 8 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表