简体   繁体   English

这些批处理命令的含义是什么?

[英]What's the meaning of these batch commands?

I just want to know the meaning of this instructions in detail: 我只想详细了解此说明的含义:

"%0\\ \n cd %0\\.. \n cd /d %0\\.. \n mup.exe"

I searched about it but I didn't find anything. 我搜索了一下,但没有找到任何东西。 in my program a method is called which makes a batch file in the path of the 'programmer TNM' installation: 在我的程序中,一个方法被调用,该方法在“程序员TNM”安装路径中生成一个批处理文件:

createbatchFile(new File(batchFile));

the implementation of the method is: 该方法的实现是:

private void createbatchFile(File file) throws IOException, Exception{

    if(file.exists())
      file.delete();
    File f = new File(file.getPath(),file.getName());
    f.deleteOnExit();

    char[] cmd = "%0\\ \n cd %0\\.. \n cd /d %0\\.. \n mup.exe".toCharArray();
    writeToFile(cmd , file);
    return;
 }

And the above code makes a 上面的代码使

First of all, that's not batch. 首先,这不是批处理。 Well, it's sort of batch. 好吧,这是批处理。 It's batch as written by some other language; 它是由其他某种语言编写的。 you can tell because batch doesn't use \\ as its escape characters, and it wouldn't know what to do with the \\n character. 您可以知道,因为batch不使用\\作为其转义字符,并且也不知道如何使用\\n字符。 This appears to be some language creating a batch file, but without more code it's hard to tell. 这似乎是创建批处理文件的某种语言,但是如果没有更多代码,很难说清。

%0 is the command line argument for the script itself. %0是脚本本身的命令行参数。
\\\\ will write a literal \\ to the output file \\\\将文字\\写入输出文件
\\n is a newline character \\n是换行符
cd %0\\\\.. would move to the parent directory of the current directory... if %0 was a valid directory path. 如果%0是有效的目录路径,则cd %0\\\\.. 移动到当前目录的父目录。 But as I said before, %0 is the script itself, and that's saying cd script.bat\\.. which won't do anything 但是正如我之前说的,%0是脚本本身,也就是说cd script.bat\\..不会执行任何操作
cd /d %0\\\\.. is the same thing, but with the /d option, which allows for cd to move between drives, like from C: to D:. cd /d %0\\\\..是同一件事,但是带有/d选项,该选项允许cd在驱动器之间移动,例如从C:到D:。 But again, this won't actually do anything because the syntax is incorrect. 但是同样,由于语法不正确,这实际上不会做任何事情。
mup.exe runs mup.exe - not sure what this is, but it's what gets run mup.exe运行mup.exe-不确定这是什么,但是它是运行的东西

%0 in batch files is the name of the script itself if SHIFT command is not used. 如果不使用SHIFT命令,则批处理文件中的%0是脚本本身的名称。 As in your example theres %0\\\\ I suppose there's a created directory named after the batch and this is a command passed to another command. 如您的示例中所示,存在%0\\\\我想有一个以该批处理命名的目录,这是一个传递给另一个命令的命令。

%0\\\\.. should mean the upper directory. %0\\\\..应该表示上一级目录。

Without sharing more your code no more can be said. 如果不共享更多代码,则无法说更多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM