Why does 7-zip.exe return "Access is denied" with these arguments/parameters?

6

1

In a batch file:

START "7-zip" /D "C:\Program Files\7-Zip\" "7z.exe" a -o <F:> testArchive F:\test

Or, alone on the cmd as:

7z.exe a -o <C:\users\user\Desktop> testArc C:users\user\desktop\test

returns "Access is denied". I would expect it to run 7-zip with the specified parameters. Why doesn't it?

Here is the code for the batch file:

@echo off 
:Variables 
set SOURCE=F:\myDocuments\ 
set DESTINATION=E:\myDocuments\ 
:If disc space is available, make tar ball or .7z or whatever of /myDocuments and place it in F:/Backups 
START "7-zip" /D "C:\Program Files\7-Zip\" "7z.exe" a -o <F:> testArchive F:\test 
pause 
:echo %SOURCE% 
:echo %DESTINATION% 
:pause 
:run create sync. on documents to H:/myDocuments 
:Otherwise, say there's not enough disc space

This doesn't happen if proper syntax is followed for the z-zip command. Access is Denied was due to a 7zip syntax error.

eichoa3I

Posted 2012-02-07T19:16:39.380

Reputation: 1 394

Are yoou running it as that user or as an admin? – EBGreen – 2012-02-07T19:18:45.197

I've tried both; i.e., right clicking the batch file and selecting 'run as administrator', and running it in an administrator's cmd window. – eichoa3I – 2012-02-07T19:22:19.480

Depending on the security on your machine, that may or may not give you access. Try shift right click -> Run as different User then run it as an actual admin account. – EBGreen – 2012-02-07T19:25:35.377

@EBGreen Still getting access is denied. I'm adding more information here: OS is WIN7, the batch file is (a work in progress): `@echo off

:Variables set SOURCE=F:\myDocuments
set DESTINATION=E:\myDocuments\

:If disc space is available, make tar ball or .7z or whatever of /myDocuments and place it in F:/Backups

START "7-zip" /D "C:\Program Files\7-Zip" "7z.exe" a -o <F:> testArchive F:\test

pause

:echo %SOURCE% :echo %DESTINATION% :pause

:run create sync. on documents to H:/myDocuments

:Otherwise, say there's not enough disc space` – eichoa3I – 2012-02-08T02:07:49.587

Ugghh...edit the question and add the new info in there please. – EBGreen – 2012-02-08T15:14:26.950

What is the permission on this file? who is the owner? – Bibhas – 2012-02-08T16:40:53.800

Does the -o parameter not need to be followed by the name of the folder, as in -oe:\mydocuments ? – sgmoore – 2012-02-08T20:29:33.063

Answers

6

Check the permissions of the 7za.exe program itself; Right click -> Properties -> Security -> (choose a user)

And check that Read & Execute is ticked. On my machine, I had Read access but not Execute.

Steve Pitchers

Posted 2012-02-07T19:16:39.380

Reputation: 271

if that does not work, do the same for the drive you are launching 7zip – JinSnow – 2015-11-22T10:45:23.477

1

I got the same issue randomly. When I add the first file it works fine, but trying to add a new file, then got the "Access denied" message.

I solved it by defining the temp directory (work directory) to 7z. Like:

7z a -w"C:\1" "C:\1\zip_file.zip" "C:\1\file_to_zip.txt"

Now it will use the work directory as "C:\1" and works fine for me.

Titarelli

Posted 2012-02-07T19:16:39.380

Reputation: 21

To others reading this: note there must not be a space between -w and the following path. – Asu – 2018-05-11T12:09:04.493

0

I solved the problem by reinstalling 7-Zip in a drive other than system drive

AMIB

Posted 2012-02-07T19:16:39.380

Reputation: 101

0

i found that changing the permissions to add "Write" solved my issue. but that leaves me with the question as to WHY NOW?. i have never had this issue before. i had to reset my win 10 due to performance issues. and as such i had to reinstall many applications. 7zip being one of em. never before have i encountered this problem. and i am unsure as to why it happened now.

rytram

Posted 2012-02-07T19:16:39.380

Reputation: 1

1You changed the permissions on what? – Scott – 2019-06-15T07:12:06.103