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

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

问题描述

我已经从正在创建的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 "HKCU\Software\Classes\*\shell\Open Folder In Rename" /ve /t REG_SZ  /d "Open With Rename" /f
REG ADD "HKCU\Software\Classes\*\shell\Open Folder In Rename\Command" /ve /t REG_SZ  /d "P:\Misc\Rename v2.0\Rename v2.0\bin\Debug\Rename 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
  • Create the file net.bat on your desktop.
  • In your file write this text: 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天全站免登陆