I am unable to retrieve Code Using Ant Migration Tool. By using Command: ant retrieve code, Gettig an Error As java.io.IOException: Access is denied.

Attaching CMD Error Screen.`

C:\Program Files\apache-ant-1.10.5\sample>ant retrieveCode
Buildfile: C:\Program Files\apache-ant-1.10.5\sample\build.xml

[sf:retrieve] Request for a retrieve submitted successfully.
[sf:retrieve] Request ID for the current retrieve task: 09S6F000004hRc1UAE
[sf:retrieve] Waiting for server to finish processing the request...
[sf:retrieve] Request Status: Succeeded

C:\Program Files\apache-ant-1.10.5\sample\build.xml:30: java.io.IOException: Access is denied
        at java.io.WinNTFileSystem.createFileExclusively(Native Method)
        at java.io.File.createNewFile(File.java:1012)
        at com.salesforce.ant.ZipUtil.unzip(ZipUtil.java:72)
        at com.salesforce.ant.RetrieveTask.handleResponse(RetrieveTask.java:140)
        at com.salesforce.ant.SFDCMDAPIAntTaskRunner.runTask(SFDCMDAPIAntTaskRunner.java:92)
        at com.salesforce.ant.RetrieveTask.execute(RetrieveTask.java:110)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
        at org.apache.tools.ant.Task.perform(Task.java:350)
        at org.apache.tools.ant.Target.execute(Target.java:449)
        at org.apache.tools.ant.Target.performTasks(Target.java:470)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1388)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1361)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
        at org.apache.tools.ant.Main.runBuild(Main.java:834)
        at org.apache.tools.ant.Main.startAnt(Main.java:223)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)

Total time: 12 seconds`
  • 1
    Are you using system -admin cred? Also the machine you are using ant, do you have write access to that folder? Mar 18, 2019 at 13:04
  • Yes, I am using System Admin Creds only and I am also having access to that folder also. Mar 18, 2019 at 13:19
  • What is written in build.xml line 30? this is the line that fails. Maybe it is a problem with writing to your local hard drive? Mar 21, 2019 at 11:51
  • How to overcome this Error @ Itai Shmida Apr 1, 2019 at 9:09

1 Answer 1


Actually, the problem above is due to saving Ant exe file in local Drive C and executing it.due to that it is unable to access build file during reterving code process, the best practice is to avoid using ant or tool in another local drive instead of C drives..

You must log in to answer this question.

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