我的批处理文件不断循环,但为什么呢? [英] My Batch File keeps looping, but why?

查看:32
本文介绍了我的批处理文件不断循环,但为什么呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从正在创建的 VB.NET 程序编写了一个批处理文件.

I have written a batch file from a VB.NET program I'm creating.

当我在 Windows XP 中双击该文件时,它会显示一个命令提示符,并且似乎在一遍又一遍地运行.

When I double click on the file in Windows XP it brings up a Command Prompt and appears to be running over and over again.

我的批处理文件如下

REG ADD "HKCUSoftwareClasses*shellOpen Folder In Rename" /ve /t REG_SZ  /d "Open With Rename" /f
REG ADD "HKCUSoftwareClasses*shellOpen Folder In RenameCommand" /ve /t REG_SZ  /d "P:MiscRename v2.0Rename v2.0inDebugRename v2.0.exe ""%1""" /f
EXIT

我无法理解我做错了什么,但是如果我打开命令提示符并从那里运行它,它会运行一次.

I can't understan what I've done wrong, but if I open a command prompt and run it from there, it runs once.

任何帮助将不胜感激!

谢谢

推荐答案

在 Windows 中,如果您有一个与 bat 文件名同名的命令行可执行文件,并且批处理文件包含此命令,则批处理文件会不断循环.

In windows, if you have a command line executable with the same name of your bat filename, and the batch file contains this command, the batch file keeps looping.

示例:

  • 在桌面上创建文件 net.bat.
  • 在你的文件中写下这段文字:net

双击该文件,它将继续循环播放.

Double click the file and it will keep looping.

这种行为的原因是命令的执行顺序.您要执行的命令位于路径中的文件夹之一中.但是批处理文件在您的当前文件夹中,因此它首先被执行,从而导致循环.

The cause of this behaviour is the order of execution of the commands. The command you want to execute is in one of the folders in your path. But the batch file is in your current folder so it gets executed first, causing the loop.

这篇关于我的批处理文件不断循环,但为什么呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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