0

First i had to suffer to make the icalcs grant full permissions to everyone in a folder as i didn't know that i should write "Tout le monde" instead of "everyone" as my windows 7 language is french and actually i needed this command for that i can unzip a zip file in the same permissions altered folder.

the code of my batch file is the following :

call xcopy glassfish-4.1.zip C:\Users\Feki\Desktop\vvv2
icacls C:\Users\Feki\Desktop\vvv2 /grant "Tout le monde":f
call C:\Program Files\Java\jdk1.7.0_40\bin>jar xf C:\Users\Feki\Desktop\vvv2\glassfish-4.1.zip
ECHO.
ECHO Press any key to exit. 
pause>null

the log indicated that the icalcs was successful but when the extraction starts i got an ' access denied' message

---- EDIT ----

i've tried to make sure that i have all permission granted on the zip file to extract so i added

icacls C:\Users\Feki\Desktop\vvv2\* /grant "Tout le monde":f

after the first icacls but the extraction still didn't work

Bardelman
  • 2,176
  • 7
  • 43
  • 70
  • i converted the batch file into an .exe file so a system popup is shown for the user to confirm actions which gonna happen but still extraction fails – Bardelman Jan 03 '15 at 10:31
  • `C:\Program Files\Java\jdk1.7.0_40\bin>jar` why is the `>` ? – npocmaka Jan 03 '15 at 11:03
  • i found it somewhere like that with the >. Now i changed it to \ but extraction still not working – Bardelman Jan 03 '15 at 11:28
  • here http://stackoverflow.com/questions/18052460/error-while-trying-to-extract-jar-file/18052502#18052502 i found someone saying that permissions aren't granted to the user on the folder containing the jar.exe. Maybe it is the default location for the extracted files, i will look how to personalize the extraction location – Bardelman Jan 03 '15 at 11:34
  • i tried with this command : call C:\Users\Feki\Desktop\vvv2>jar xf glassfish-4.1.zip but it doesn't work too – Bardelman Jan 03 '15 at 11:42
  • well, right now i still have problems with my java home variable. i ll install evevrything again and try that same command later. Thanx – Bardelman Jan 03 '15 at 11:49
  • i checked that java_home and the path are set but still it didn't work – Bardelman Jan 03 '15 at 13:21
  • you need to set `%java_home%\bin` to the path.... – npocmaka Jan 03 '15 at 14:05
  • i did but it's not the problem. i'm sure it's about permissions. – Bardelman Jan 03 '15 at 14:43
  • Just try to call the `jar` executable without the file parameter to see if you have the permissions to call it. – unwichtich Jan 03 '15 at 16:30
  • i have permissions to call it but it doesn't work – Bardelman Jan 03 '15 at 18:39

1 Answers1

1

First I want to say that I think your script looks a little bit weired.

In the first line

call xcopy glassfish-4.1.zip C:\Users\Feki\Desktop\vvv2

you are copying the zip file to a folder on the Desktop, this already requires write access rights in C:\Users\Feki\Desktop\vvv2 or it won't work.

In the next line you try to set the access rights for this folder:

icacls C:\Users\Feki\Desktop\vvv2 /grant "Tout le monde":f

As described, this doesn't make much sense because you already have written the zip file to this folder, therefore you must have at least write access rights.

Now to the problem, the call:

call C:\Program Files\Java\jdk1.7.0_40\bin>jar xf C:\Users\Feki\Desktop\vvv2\glassfish-4.1.zip

is something which shouldn't work anyway because there is a space between Program and Files. I don't know what this bin>jar should be but if this works for you, then you may use it in this way.

I would write it like this:

call "%ProgramFiles%\Java\jdk1.7.0_40\bin\jar.exe" xf C:\Users\Feki\Desktop\vvv2\glassfish-4.1.zip

If this call gives you an Access denied. message then you probably don't have write access rights in the current path of the command line.

Note that the jar utility will extract the content of the zip file to the current path of the command line. That means if you are in c:\ then it will extract the content to c:\ and if you are in c:\bla\ then it will extract the content to c:\bla\. (It doesn't make a difference if you call it with the full path or only jar when it is in your PATH var.)

So this looks like you don't have the right access rights in the path where your glassfish-4.1.zip is, because this is the current path of your command line. I guess you want to extract the content to the folder on the Desktop. To do this, just change the current path to this folder before issuing the extract call.

I guess the script could look like this:

call xcopy glassfish-4.1.zip C:\Users\Feki\Desktop\vvv2
cd C:\Users\Feki\Desktop\vvv2\
call "%ProgramFiles%\Java\jdk1.7.0_40\bin\jar.exe" xf glassfish-4.1.zip

See also:

Community
  • 1
  • 1
unwichtich
  • 13,712
  • 4
  • 53
  • 66
  • jar only worked for me locally (in the current folder) and it never worked for any file placed in a remote folder. this is my first days working with the batch scriptinig and i forgot that it's like in dos where i can use CD... so Thanks ALOT man!! – Bardelman Jan 03 '15 at 19:10