This code works on Window 7
First Select Folder Using JFileChooser to LOCK :
JFileChooser chooser = new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.showOpenDialog(this);
File f = chooser.getSelectedFile();
String path = f.getAbsolutePath();
fName = f.getName();
Create bat file through program
String cmd2 = "ren " + path + " " + fName + ".{ED7BA470-8E54-465E-825C-99712043E01C}";
File f2 = new File("lock.bat");
FileOutputStream fos2 = new FileOutputStream(f2);
DataOutputStream dos2 = new DataOutputStream(fos2);
dos2.writeBytes(cmd2);
fos2.close();
Execute this bat file
Runtime.getRuntime().exec("lock.bat");
and to UNLOCK just change command cmd2 as
String cmd2 = "ren "+ fName + ".{ED7BA470-8E54-465E-825C-99712043E01C} "
+ folderPath
;
unlock is not working
ReplyDelete