Reputation: 1519
I have used the following code to make a folder undeletable in my java project. It works fine. When I create an exe of my project the dos prompt doesn't get disappeared.
cmd.exe /c start icacls "folder name" /e /c /d %username%
I also tried without opening the dos prompt. But it doesn't work.
icacls ONGX32/winkrl /e /c /d %username%
Upvotes: 0
Views: 462
Reputation: 1519
I found a simple way. Created a .bat temporary file consists of that command. Used that .bat file. It didn't open the command prompt.
Upvotes: 0
Reputation: 6642
In a command prompt, the command exit
closes it.
You can run multiple commands on one line using the &&
command separator.
It should be something like this:
cmd /c icacls "folder name" /e /c /d %username% && exit
Upvotes: 0
Reputation: 4421
Instead use:
cmd /c icacls "folder name" /e /c /d %username%
start
is sort of the same as cmd /c
, so you don't need both.
Upvotes: 1
Reputation: 29886
The variable %username%
is replaced by its value by cmd.exe.
You need to get it with System.getenv("username")
, and replace it yourself in the command string.
Edit. You may also need to use the fully qualified path to icacls.exe.
Upvotes: 0