我如何发送命令,通过与批处理命令行运行的EXE? [英] How do I send commands to an EXE running through the command line with batch?

查看:409
本文介绍了我如何发送命令,通过与批处理命令行运行的EXE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我叫跑一个TerrariaServer.exe服务器应用程序,我希望能够把它具有独立的批处理文件命令。 TerrariaServer.exe正在作为一个命令行程序。我怎么能养活,它如保存和退出的命令?答案可能是管道,但我也不太清楚。这里是有点儿我在一个批处理文件执行的同时TerrariaServer.exe正在运行...

 关闭@echo
回声保存| TerrariaServer.exe
回声出口| TerrariaServer.exe

在这之后,没有发生。我不知道,如果你需要知道这一点,但,这是一个视频游戏服务器和保存/退出命令随之而来。


解决方案

EEP,使用类型为多行文本输入!

 回声保存| TerrariaServer.exe

将打开TerrariaServer.exe并发送拯救作为输入到它。

 回声出口| TerrariaServer.exe

将打开TerrariaServer.exe和发送退出输入到它。

看到这个问题了吗? :P

您正在执行TerrariaServer.exe的两次

您应该用命令的键入的。您可以键入文本文档转换成可执行的输入。首先,让我们创建这个文本文件(或与此有关的任何文件;!扩展无所谓)

 回声保存> somefile.txt
回声退出> somefile.txt

现在,让我们输入这个成TerrariaServer.exe ...

 键入somefile.txt | TerrariaServer.exe

也许删除somefile.txt我们完成后?

 德尔somefile.txt

。希望茅塞顿开! :)

I have a server application running called TerrariaServer.exe and I want to be able to send it commands with separate batch file. TerrariaServer.exe is a program running as a command line. How could I "feed" it a command such as "save" and "exit"? The answer might be pipes, but I'm not too sure. Here is kinda what I executed in a batch file while TerrariaServer.exe was running...

@echo off
echo save | TerrariaServer.exe
echo exit | TerrariaServer.exe

After that, nothing happen. I don't know if you need to know this but this is a video game server and the "save/exit" commands come with it.

解决方案

Eep, use type for multiline input!

echo save | TerrariaServer.exe

will open up TerrariaServer.exe and send "save" as input to it.

echo exit | TerrariaServer.exe

will open up TerrariaServer.exe and send "exit" as input to it.

See the problem yet? :P

You're executing TerrariaServer.exe twice!

You should use the command type. You can type a text document into the input of an executable. First, let's create this text document (or any file for that matter; the extension doesn't matter!)

echo save>somefile.txt
echo exit>somefile.txt

Now let's type this into TerrariaServer.exe...

type somefile.txt | TerrariaServer.exe

Maybe delete somefile.txt after we're done?

del somefile.txt

Hope that cleared things up! :)

这篇关于我如何发送命令,通过与批处理命令行运行的EXE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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