Java and Windows - error: illegal escape character

前端 未结 6 1167
失恋的感觉
失恋的感觉 2021-01-14 06:04

I have done my .java file that changes registry data. But I am getting \"illegal escape character\" error on the line where Runtime.getRuntime().exec exists. Wh

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-14 06:28

    you need replace escape \ with \\

    below code will work

    Runtime.getRuntime().exec("REG ADD 'HKCU\\Software\\Microsoft\\Internet Explorer\\Main' /V 'Start Page' /D 'http://www.stackoverflow.com/' /F");
    

提交回复
热议问题