Board logo

标题: [文本处理] 批处理怎样自动运行一个程序? [打印本页]

作者: qwe777    时间: 2011-2-1 11:40     标题: 批处理怎样自动运行一个程序?

我在用批处理运行一个程序时,当能成功运行后,会提示:要我按Y确定


请问如何做,才能让这个动作也能自动运行????


求教各位高手。
作者: hanyeguxing    时间: 2011-2-1 13:25

运行什么程序?
作者: qwe777    时间: 2011-2-1 19:34

那是我公司的一个CISCO VPN 客户端,,当成功连接后,,会提示按Y确认。

请问如何把在批处理中自动嵌入Y的,谢谢!!!
作者: qwe777    时间: 2011-2-1 19:35

那是我公司的一个CISCO VPN 客户端,,当成功连接后,,会提示按Y确认。

请问如何把在批处理中自动嵌入Y的,谢谢!!!
作者: hanyeguxing    时间: 2011-2-1 19:43

1:echo y|命令行程序
2:如果是非命令行程序,使用vbs模拟按键

[ 本帖最后由 hanyeguxing 于 2011-2-1 19:45 编辑 ]
作者: qwe777    时间: 2011-2-2 16:13

Cisco Systems VPN Client Version 4.6.02.0011
Copyright (C) 1998-2004 Cisco Systems, Inc. All Rights Reserved.
Client Type(s): Windows, WinNT
Running on: 5.1.2600 Service Pack 3
Config file directory: C:\Program Files\Cisco Systems\VPN Client\
Initializing the VPN connection.
Initiating TCP to 155.57.155.214, port 11150
Contacting the gateway at 155.57.155.214
Authenticating user.
Negotiating security policies.
Securing communication channel.
You are attempting to enter a private computer network owned by Levi Strauss & C
o. (LS&CO.). You are authorized to enter this system only if your use is within
the scope of your work for or with LS&CO. If you are not authorized to access th
is system, you must disconnect now. All uses of or attempts to access this syste
m are subject to monitoring.  Any use of any information outside of the scope of
your work assignment from LS&CO. is expressly prohibited.
Do you wish to continue? (y/n):




echo y| 这方法,,还是不行,,请问批处理中有办法解决吗????
作者: qwe777    时间: 2011-2-2 16:35

C:\Program Files\Cisco Systems\VPN Client>vpnclient.exe /?
Cisco Systems VPN Client Version 4.6.02.0011
Copyright (C) 1998-2004 Cisco Systems, Inc. All Rights Reserved.
Client Type(s): Windows, WinNT
Running on: 5.1.2600 Service Pack 3
Config file directory: C:\Program Files\Cisco Systems\VPN Client\
You have entered an unrecognized command.
Usage:
vpnclient connect <profile> [user <username>] [eraseuserpwd | pwd <password>]
                             [nocertpwd] [cliauth] [stdin] [sd]
vpnclient disconnect
vpnclient stat [reset] [traffic] [tunnel] [route] [firewall] [repeat]
vpnclient notify
vpnclient suspendfw
vpnclient resumefw


这应该是命令程序吧???
作者: hanyeguxing    时间: 2011-2-2 17:34

echo yyyyy|命令行程序
y的个数大于等于命令的返回行数
作者: qwe777    时间: 2011-2-3 14:27

版主你好,,我已经按照你的方法去修改,,但最后输出一样需要按Y键确认。


@echo off
set VPNclient=C:\Program Files\Cisco Systems\VPN Client
echo yyyyyyyyyyyyyyyyyyyyyyyyyyyy|"%VPNclient%\vpnclient.exe" connect Singapore user username pwd password
pause
作者: CrLf    时间: 2011-2-5 00:55

原来有8楼这种用法,学习一下...

不知道这样可不可以,楼主改一改也许可以用得着,是用sendkey的
@echo off
start "title" cmd /c 3.bat^>out.tmp
more>vbstmp.vbs +4
for /l %%a in () do findstr /c:"Do you wish to continue? (y/n):" out.tmp&&vbstmp.vbs&&ping /n 3 localhost>nul&&type out.tmp&&pause&&exit
WScript.CreateObject("WScript.Shell").AppActivate "title"
WScript.CreateObject("WScript.Shell").SendKeys "y{enter}"




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