当涉及到vb脚本甚至命令行时,我是一个完全的业余爱好者所以请耐心等待..
我已经使用Wshshell.sendkeys为发送密钥创建了一个vb脚本send.vbs。 在这个脚本中,我使用vsh命令进入vshell,我输入vsh后得到两个选项,其中我选择选项2,然后我执行一个命令,其输出被重定向到一个文本文件。 我然后将此文件ftp到不同的服务器。 现在我想安排这个vb脚本每10分钟运行一次。 现在,如果我双击这个脚本文件,它只是打开一个黑色的窗口片刻并关闭它。 命令不会执行。 但是当我手动打开命令窗口然后我去脚本所在的路径然后我执行它,它工作正常,我得到了所需的输出。
我尝试使用cscript send.vbs编写批处理文件,并安排相同的操作每10分钟运行一次。 但是这个批处理文件没有运行vbscript。 any1可以帮我写一个批处理文件,它将打开一个命令提示符,然后在该命令提示符下运行thi vb脚本。 脚本如下:
Set WshShell = wscript.CreateObject("wscript.Shell") wshshell.sendkeys "vsh" wshshell.sendkeys "{ENTER}" wshshell.sendkeys "2" wshshell.sendkeys "{ENTER}" wshshell.sendkeys "tls display agents > Agentstat.txt" wshshell.sendkeys "{ENTER}" wshshell.sendkeys "quit" wshshell.sendkeys "{ENTER}"任何帮助都非常感谢..谢谢!!
I am a complete amateur when it comes to vb scripting or even command line so please bear with me..
I have created a vb script send.vbs for Sending Keys using Wshshell.sendkeys. In this script, i am going into vshell using vsh command, i get two options after i enter vsh, out of which i select option 2, and then i am executing a command whose output is redirected to a text file. i then ftp this file to a diferent server. Now i want to schedule this vb script to run every 10 min. Now, if i double click this script file, it just opens a black window for a moment and shuts it down. The commands are not executed. But when i open a command window manually and then i go to the path where the script is and then i execute it, it works fine and i get the desired output.
I tried writing a batch file with cscript send.vbs and scheduling the same to run every 10 min. but this batch file does not run the vbscript. Can any1 help me to write a batch fiel which will open a command prompt and then run thi vb script in that command prompt. The script is as follows:
Set WshShell = wscript.CreateObject("wscript.Shell") wshshell.sendkeys "vsh" wshshell.sendkeys "{ENTER}" wshshell.sendkeys "2" wshshell.sendkeys "{ENTER}" wshshell.sendkeys "tls display agents > Agentstat.txt" wshshell.sendkeys "{ENTER}" wshshell.sendkeys "quit" wshshell.sendkeys "{ENTER}"Any help is highly appreciated.. Thanks !!
最满意答案
干得好 ...
Set WshShell = wscript.CreateObject("wscript.Shell") WshShell.Run "cmd" WScript.Sleep 100 WshShell.AppActivate "C:\Windows\system32\cmd.exe" WScript.Sleep 100 wshshell.sendkeys "vsh" wshshell.sendkeys "{ENTER}" wshshell.sendkeys "2" wshshell.sendkeys "{ENTER}" wshshell.sendkeys "tls display agents > Agentstat.txt" wshshell.sendkeys "{ENTER}" wshshell.sendkeys "PAUSE" wshshell.sendkeys "{ENTER}" wshshell.sendkeys "quit" wshshell.sendkeys "{ENTER}"Here you go ...
Set WshShell = wscript.CreateObject("wscript.Shell") WshShell.Run "cmd" WScript.Sleep 100 WshShell.AppActivate "C:\Windows\system32\cmd.exe" WScript.Sleep 100 wshshell.sendkeys "vsh" wshshell.sendkeys "{ENTER}" wshshell.sendkeys "2" wshshell.sendkeys "{ENTER}" wshshell.sendkeys "tls display agents > Agentstat.txt" wshshell.sendkeys "{ENTER}" wshshell.sendkeys "PAUSE" wshshell.sendkeys "{ENTER}" wshshell.sendkeys "quit" wshshell.sendkeys "{ENTER}"更多推荐
发布评论