cmd 中执行多个命令?

发布于 2024-08-09 22:40:20 字数 317 浏览 5 评论 0原文

我想使用 attrib隐藏多个文件+s +h 但它在第一个文件夹之后停止。 我有这个...

@ech off
attrib z:\test +s +h
attrib C:\Documents and Settings\Administrator\Desktop\test +s +h

是的,我有两个驱动器。但它会在第一个文件夹之后停止执行。我如何让它执行这两个命令。我知道 call 命令,但这是唯一的方法吗? DOS 不可能有这么大的缺陷,你不能在一个批处理文件中执行多个命令。

I want to hide multiple files with the attrib <file path> +s +h but it stops after the first folder.
I have this...

@ech off
attrib z:\test +s +h
attrib C:\Documents and Settings\Administrator\Desktop\test +s +h

Yes, I have two drives. But it stops execution after the first folder. How do I make it execute both commands. I know about the call command, but is that the only way? There can't be this big of a flaw in DOS, where you can't execute multiple commands in one batch file.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

佞臣 2024-08-16 22:40:20

如果你没有犯错误的话(在 DOS 中,开关位于文件夹之前),它应该可以正常工作。试试这个:

@echo off
REM Add /s after the *.* to include subfolders
attrib +s +h z:\test\*.*
REM Note the double quotes around paths that have embedded spaces
attrib +s +h "c:\Documents and Settings\Adminstrator\Desktop\Test\*.*"

同样,你的问题是你正在执行“attrib [文件夹] [属性开关]”,而 attrib.exe 需要“attrib [属性开关] [文件夹]”。 感谢 JimG以便更正。这个问题可能与我的第二个 REM 语句有关,该语句涉及路径周围缺少双引号和空格。

有关 attrib.exe 的详细信息,请在命令提示符下键入:

C:\> attrib /?

It should work fine if you haven't made a mistake (which you have - in DOS, the switches come before the folder). Try this:

@echo off
REM Add /s after the *.* to include subfolders
attrib +s +h z:\test\*.*
REM Note the double quotes around paths that have embedded spaces
attrib +s +h "c:\Documents and Settings\Adminstrator\Desktop\Test\*.*"

Again, your problem is you're doing "attrib [folder] [attribute switches]", where attrib.exe wants "attrib [attribute switches] [folder]" instead. Thanks to JimG for the correction. The problem is probably related to my second REM statement about the missing double-quotes around the path with spaces.

For more info about attrib.exe, type this at a command prompt:

C:\> attrib /?
画离情绘悲伤 2024-08-16 22:40:20

你缺少 /S 标志

you are missing the /S flag

无尽的现实 2024-08-16 22:40:20

您的第二个命令不起作用,因为您没有引用其中包含空格的路径。或者,或者您的路径上在 attrib.exe 之前有一个名为 attrib.bat 的批处理文件(但我怀疑是这种情况)。您可以使用 attrib.exe 而不仅仅是 attrib 来测试它。

CALL 仅在运行其他批处理文件时才需要,而不是 .exe 文件。

Your second command doesn't work because you haven't quoted the path with spaces in it. Either that, or you have a batch file called attrib.bat on your path before attrib.exe (but I doubt this is the case). You could test it by using attrib.exe instead of just attrib.

CALL is only necessary for running other batch files, not .exe files.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文