Batch file: Reading and activate commands from unknown files

感情迁移 提交于 2019-12-25 01:49:36

问题


I know the title doesn't make sense, but I have one question. I have made this file called Test.bin and here's whats inside the .bin file:

echo Hello World

Since its a test file, I've been trying to see if i can make a batch file that can read the commands in the .bin file and output it onto the console.


回答1:


Not sure what you are trying to do exactly, but I think you have two options:

Rename test.bin as test.bat and run it with:

test

Start a new command interpreter and send it your commands:

cmd < test.bin



回答2:


You could also use the copy command. However, for this to work the test.bin file should be in the same directory/folder. Alternatively, you can specify the file's path.

Your code should look something like this:

@echo off
copy test.bin

Or, using the filepath method (pretending its on your desktop):

@echo off
copy C:/users/me/Desktop/test.bin


来源:https://stackoverflow.com/questions/23860361/batch-file-reading-and-activate-commands-from-unknown-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!