MSDOS在屏幕上打印整个批处理文件,而不是执行 [英] MSDOS prints the whole batch file on screen instead of executing

查看:105
本文介绍了MSDOS在屏幕上打印整个批处理文件,而不是执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我尝试执行一个批处理文件时,即使是一个简单的文件,它都会打印出整个内容,而不是执行它.我已经在MS-DOS 3.3和4.0上尝试过,都可以做到这一点.如果我在命令提示符下单独执行每个命令(尽管它们可以工作)(因此,如果我在命令提示符下键入"pause",它将暂停,与其他命令相同).批处理文件在Windows 2000(我拥有的唯一一台可以读取720k软盘的计算机)上可以很好地执行 我的代码在下面,名为test.bat:

Whenever I try to execute a batch file, even a simple one, it prints the whole thing out instead of executing it. I have tried it on MS-DOS 3.3 and 4.0, both do this. If I execute each command individually in the command prompt though they work (so if I type "pause" in the command prompt it will pause, same with the other commands). The batch file executes fine in Windows 2000 (the only computer I had that can read 720k floppy disks) My code is below, named test.bat:

@echo off
cls
echo Hello World!
pause

执行时的样子,上面的文字test是我执行的程序名称:

What it looks like when executed, the text saying test at the top being the program name I executed:

推荐答案

就像其他人在注释中提到的那样,您的test.bat文件不包含不可见的回车符-仅换行符. Unix/Linux很好,但是DOS两者都需要.整个文件被视为一行.

As others have mentioned in the comments, your test.bat file doesn't contain the invisible carriage return characters - only linefeed characters. That's fine for Unix/Linux, but DOS needs both. The whole file is being treated as one line.

由于这是一个简单的文件,您可以仅使用命令copy con test.bat重新输入它,并在完成后输入CTRL+Z.不幸的是,这只能让您创建 new 文件,而不能编辑现有文件.

Since this is a simple file, you could just retype it with the command copy con test.bat and type CTRL+Z when you are finished. Unfortunately, this will only let you create new files, not edit existing ones.

您已经发现,MS-DOS 4早于edit命令.但是它确实带有另一个(更烦人的)文本编辑器:edlin.

As you've discovered, MS-DOS 4 predates the edit command. But it did come with another (more annoying) text editor: edlin.

您一次只能编辑一行,而键盘控件也不是很直观,因此请查看此链接以获取有关导航界面的详细信息:

You can only edit one line at a time and the keyboard controls are not exactly intuitive, so check out this link for details on navigating the interface: http://www.computerhope.com/edlin.htm

这篇关于MSDOS在屏幕上打印整个批处理文件,而不是执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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