Undeletable Folder in java

后端 未结 2 666
终归单人心
终归单人心 2021-01-28 23:32

I tried to create a Undeletable folder using java code. I use the command \"cacls (Foldername) /e /c /d %username%\" in command prompt it worke

相关标签:
2条回答
  • 2021-01-28 23:54

    Try this code it works fine.It suits for both file and folder.

    public class Undeletable {
    
        public static void main(String[] args) {
    
            Runtime runtime=Runtime.getRuntime();
            try {
                Process process= runtime.exec("cmd.exe /c  start cacls text.txt /e /d %username%");
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        } 
    
    
    }
    
    0 讨论(0)
  • 2021-01-29 00:12

    Is the current working directory set to the parent directory of your "hidden" directory when you invoke the command? You can change it with ProcessBuilder.directory(java.io.File).

    0 讨论(0)
提交回复
热议问题