我已经完成了更改注册表数据的 .java 文件。但是我在 Runtime.getRuntime().exec 存在的行上收到“非法转义字符”错误。我的错误在哪里?

import java.util.*;
import java.applet.Applet;
import java.awt.*;

class test {
  public static void main(String args[]) {
      try {
          Runtime.getRuntime().exec("REG ADD 'HKCU\Software\Microsoft\Internet Explorer\Main' /V 'Start Page' /D 'http://www.stackoverflow.com/' /F");
      } catch (Exception e) {
          System.out.println("Error ocured!");
      }
  }
}

最佳答案

您需要转义路径中使用的反斜杠。

String windowsPath = "\\Users\\FunkyGuy\\My Documents\\Hello.txt";

关于Java 和 Windows - 错误 : illegal escape character,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12889275/

10-12 00:39
查看更多