创建打开多个窗口的批处理文件 [英] Creating Batch File that Opens numerous windows

查看:107
本文介绍了创建打开多个窗口的批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望这个澄清比以前好多了。



所以,我正在尝试创建一个批处理文件,它将执行以下操作。我的最终目标是在底部,但是现在我只是停留在获取一个批处理文件以启动多个命令提示。我只是看看是否可以这样做,或者我是否需要为每个作业制作批处理文件,然后制作一个主批处理文件,告诉每个人该怎么做。



1.在启动时运行(我知道如何)。

2. Ping< hostname>

3. Ping< hostname's>

4.每5分钟跟踪路由到主机名和主机名的IP。

5.创建所有结果的每日日志。



不幸的是,我只熟悉批处理文件,所以如果有人有任何更好的建议,我很乐意听到它们。



以下是我的电脑统计数据:



主机:Windows 7旗舰版64位

Vmware Player 7 Pro免费(非商业用途)

Vmware访客:Windows XP专业版SP3



我只使用的原因XP是因为我与显卡有冲突的视频驱动程序问题..它运行的驱动程序只设计用于XP,所以如果我不小心,我将获得我的Win&主办。



如果我甚至可以在CentOS中实现同样的功能,那么也会有很多帮助(看到我可以做CLI)。



---------------



无论如何,我有以下部分:



------- START -------

@echo off

ping -t< mymailserver.com>

调用C:\ WINDOWS \ System32 \ cmd.exe / Kping -t 192.168.255.255

- ------结束---------



我希望每个命令都在自己的窗口中打开。像ping< host>在一个窗口。 Ping< hostname ip =>在另一个,每隔5分钟,traceroute将弹出并在第3个命令提示符窗口中运行。



我也试过(下面的命令)但是我无法得到弹出一个新窗口。



start cmdping -t 192.168.255.255

start cmd / Kping -t 192.168 .255.255

cmdping -t 192.168.255.255

cmd / Kping -t 192.168.255.255



我读过很多论坛,语法,我无法找到方法。




从回答移开:

我还没有那么远的项目,但如果是这样的话,是否需要为每个工作创建单独的批处理文件?因为我希望ping每隔5分钟保持连续和跟踪路由?



目前,我正在努力让它打开第二个命令提示窗口运行第二次连续ping ...这是我目前的问题。



我已经阅读了所有可用的评论/解决方案,而Powershell我会调查它。



这是一个小背景故事(我会坚持到底)。我有一个最终用户抱怨他们正在丢失与我们的域/邮件托管服务器的物理连接。他们在美国中部,我在美国。每次他们报告问题时,我都会搜索所述服务器上的邮件日志,错误日志,并且在服务器上找不到物理,逻辑或停机时间。此外,我们还有其他最终用户,不会同时报告任何问题。我有这台电脑关闭整个网络(远程访问只能力),所以我甚至无法到达该位置,没有人在附近的服务器。我希望能够设置这个以便下次这个特定的欧盟报告说这个问题时,我可以在有问题的日期/时间上提取历史记录,以便将我的连接状态与他们的时间表进行比较。





最终目标如下:



一个命令提示符使用命令:Ping -t 220.54.19.4



使用命令的一个命令提示符:Ping -t mail.domainishere.com



使用命令的一个命令提示符:tracert 220.54.19.4



使用命令的一个命令提示符:tracert mail.domainishere.com



所以在所有4个命令提示中同时运行。 2 Traceroute命令提示,我想每5分钟,所以如果我可以重复说最终用户正在经历的内容,我可以看到连接丢失的位置。



在traceroutes运行结束时,我想将从间隔中获取的信息发送到日志文件中,这样,我可以保留详细历史记录,以防他们抱怨任何连接问题,我可以拉说出时间/日期记录并查看它们的内容并与它们所遇到的问题进行比较。



每天结束时,所有ping结果(我更喜欢它们)要被移动到日志文件以保留详细历史记录。

解决方案

某些Windows计划任务怎么样?


< blockquote>请参阅我对该问题的评论。我觉得你在这里的位置非常困难。如果涉及软件工程,很难帮助不是软件工程师(我从你的陈述中推断出不幸的是,我只熟悉批处理文件)。



如果你理性地分析批处理文件有什么问题,那么中心点可能是:缺乏任何合理可用的调试。所以,我认为最接近的方法之一就是使用Microsoft Windows PowerShell:

http: //en.wikipedia.org/wiki/Windows_PowerShell [ ^ ],

http://microsoft.com/powershell [ ^ ]。



最新版本建议不仅可用,但非常方便的调试器。



尽管如此,这仍然接近编程,实际上几乎可以为您提供.NET编程的所有功能,即使在脚本设置和没有能力的情况下也是如此构建任何程序集或可执行模块。但你可以使用一些编程模型的子集,也就是说,与批处理相同,但也可以调试,还有更多。



正如我所说,任何事情像每5分钟一次对我来说听起来很可疑。所有可以被理解为拉技术的东西都可以被认为是邪恶的,有些浪费但效率低下的东西。 (请参阅 http://en.wikipedia.org/wiki/Pull_technology [ ^ ],网站帐户的应用程序'仪表板 [ ^ ]。



尽管如此,您的信息远远不够判断。只有当你清楚地了解你的最终目标时,我们才能讨论你所有的问题(不仅仅是拉动)。



-SA

I hope this clarification is a lot better than what it was previously.

So, I am trying to create a batch file that will do the following.. I have the ultimate goal at the bottom, but right now I am ONLY stuck at getting one batch file to launch multiple command prompts. I am just seeing if this can be done, or if I would need to make a batch file for each job, and then make a master batch file that would tell each individual what to do.

1. Run on startup(which I know how).
2. Ping <hostname>
3. Ping <hostname's>
4. Traceroute to Hostname and Hostname's IP every 5 minutes.
5. Create daily logs of all results.

Unfortunately, I am familiar with Batch Files only, so if anyone has any better suggestions I would love to hear them.

Here are my computer stats:

Host: Windows 7 Ultimate 64 bit
Vmware Player 7 Pro Free(Non-Commercial Use)
Vmware Guest: Windows XP Pro SP3

Only reason I am using XP is because I am having conflict video driver issues with the graphics card.. It is running on a driver that is designed for XP only, so if I am not careful I will get a BSOD on my Win & host.

If I could even acheive the same function in CentOS that would help out a lot as well(seeing that I can just do it CLI).

---------------

Anyways, I have the following portion:

-------START-------
@echo off
ping -t <mymailserver.com>
call C:\WINDOWS\System32\cmd.exe /K "ping -t 192.168.255.255"
-------END---------

I want each command to open in its own window. Like the ping <host> in one window. Ping <hostname ip=""> in another, and every 5 minutes the traceroute will pop up and run in a 3rd command prompt window.

I also tried(commands below) but I can't get a new window to pop up.

start cmd "ping -t 192.168.255.255"
start cmd /K "ping -t 192.168.255.255"
cmd "ping -t 192.168.255.255"
cmd /K "ping -t 192.168.255.255"

I've read numerous forums, syntax, and I am not able to find the way to do it.


Moved from "answer":
Well I'm not that far down the project yet, but if that is case, wouldn't it involved having to create separate batch files for each job? since I want the pings to stay continuous and the traceroute every 5 minutes?

At the moment, I am fighting it trying to get it to open a second command prompt window to run the second continuous ping... That is my current issue.

I've read all the comments/solutions available, and Powershell I will look into it.

Here's a little backstory(I will keep to the point). I have an end user that is complaining that they are losing physical connection to our Domain/Mail Hosting Server. They are in the Mid-U.S, and I am in AL. Each time they report the issue, I search the mail logs, error logs on said server and found no physical, logical, or down time on the server. Also we have other end users as well that do not report any issues at the same time. I have this computer off the complete network(remote access only ability) so I can't even get out to the location and no one is near said server. I am hoping that to get this set up so that the next time this particular EU reports said issue, I can pull the history logs on the date/time in question to compare my connection status with their timeframe.


The ultimate goal of this is the following:

One Command Prompt using the command: Ping -t 220.54.19.4

One Command Prompt using the command: Ping -t mail.domainishere.com

One Command Prompt using the command: tracert 220.54.19.4

One Command Prompt using the command: tracert mail.domainishere.com

So in all 4 Command Prompts running simutaneous. The 2 Traceroute Command Prompts, I want to every 5 minutes so that if I CAN repeat what said end user is going through, I can see where the connection is being lost at.

At the end of the traceroutes ran, I want to send the information that was gotten from the interval into a log file so that way, I can keep a detail history in case they complain of any connection issues, I can pull the said time/date log and view what they were and compare to the issues they have.

At the end of each day, all the ping results(which I prefer them to be timestamped) to be moved to a log file to keep a detail history.

解决方案

How about some Windows Scheduled Tasks?


Please see my comment to the question. I feel your position here is pretty difficult. If a software engineering is involved, it's really hard to help to not a software engineer (something I deduces from your statement "Unfortunately, I am familiar with Batch Files only").

If you rationally analyze what's wrong with batch files, the central point will probably be: the lack of any reasonably usable debugging. So, I thought that one of the closest approaches would be getting to use Microsoft Windows PowerShell instead:
http://en.wikipedia.org/wiki/Windows_PowerShell[^],
http://microsoft.com/powershell[^].

The latest version suggests not just usable, but wonderfully convenient debugger.

Still, this is close to programming and will actually give you nearly all power of .NET programming, even though in scripting setting and without the ability to build any assemblies or executable modules. But you could use some sub-set of programming model, that is, same as batch, but also with debugging, and a lot more.

As I said, anything like "every 5 minutes" sounds suspicious to me. Everything which can be understood as pull technology can be considered as evil, some wasteful and yet inefficient thing. (Please see http://en.wikipedia.org/wiki/Pull_technology[^], Application 'dashboard' for website accounts[^]).

Nevertheless, your information is by far not enough for judgement. We could discuss all your problems (not just pull) only if you give us clear idea of your ultimate goals.

—SA


这篇关于创建打开多个窗口的批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆