Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
    
Are yoou running it as that user or as an admin? – EBGreen Feb 7 '12 at 19:18
    
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. – jhstuckey Feb 7 '12 at 19:22
    
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 Feb 7 '12 at 19:25
    
@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 – jhstuckey Feb 8 '12 at 2:07
    
Ugghh...edit the question and add the new info in there please. – EBGreen Feb 8 '12 at 15:14

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.

share|improve this answer
    
if that does not work, do the same for the drive you are launching 7zip – Guillaume Combot Nov 22 '15 at 10:45

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.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .