Skip Links

Network World

IT Asked & Answered

AdviceGadgetsToolsITAA Home

Changing permissions on DOS files

Average: 4 (3 votes)

How could you change the permissions for a file in a DOS environment using the Windows CACLS command by calling it from within a Java program using Runtime.exec()? I used this code

String command2=
"cmd.exe /c CACLS E:\\temp\\temp.txt /G dev\\john.doe:w";
Process process2= runtime.exec(command2);
process2.waitFor();
System.out.println("Exit value : "+ process2.exitValue());

but the command needs Y/N while executing from DOS but from Java I could not send it so the process hangs!

Blass
Answer by Steve Blass

Expert's answer

n/a