通过批处理文件打开命令提示符来调用和执行vb脚本(Calling and executing vb script by opening command prompt through Batch fil

编程入门 行业动态 更新时间:2024-10-24 22:18:40
通过批处理文件打开命令提示符来调用和执行vb脚本(Calling and executing vb script by opening command prompt through Batch file)

当涉及到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}"

更多推荐

本文发布于:2023-07-14 20:33:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1107226.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   命令提示符   批处理文件   Calling   executing

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!