SCCM Task Sequence Failed With Error Code 0x80070002 | Resolved

Jason Barrett Jason Barrett | | Task Sequence

Today my SCCM Task Sequence started showing the error “Command line execution failed (80070002)” and my task sequence failed.

Error Code 0x80070002 means “The system cannot find the file specified” which is usually caused by an issue with the distribution point or the package / application itself.

I have seen this error many times and I have found a few different fixes which I will cover below.

Troubleshooting Error Code 0x80070002

To fix this error we need to find out exactly what is causing the issue by looking at the SMSTS.log file.  To do this follow these steps

  1. Run the task sequence
  2. Press F8 and this will bring up the command prompt
  3. Wait for the error to appear (As shown below)
    sccm task sequence failed with 80070002
  4. Now open the SMSTS.log file which will be in one of the following locations
  • X:\Windows\Temp\Smstslog\Smsts.log
  • X:\Smstslog\Smsts.log and C:\_SMSTaskSequence\Logs\Smstslog\Smsts.log
  • C:\_SMSTaskSequence\Logs\Smstslog\Smsts.log
  • C:\Windows\Ccm\Logs\Smstslog\Smsts.log
  • C:\Windows\Ccm\Logs\Smsts.log

Now search for 0x80070002 and you should see some errors like the following ones

  • CreateProcess failed. Code(0x80070002)
  • Command line execution failed (80070002)
  • clCommandLine.Execute( uOptions, pszWorkingDir, lpDesktop), HRESULT=80070002 (runcommandline.cpp,465)
  • Failed to execute command line
  • Install Software failed to run command line, hr=0x80070002
  • Failed to run the action: Remove Google Chrome Desktop Shortcut. Error -2147024894
  • Failed to create environment, hresult 80070002

Command line execution failed (80070002)

Looking at the logs you can see the task sequence step “Remove Google Chrome Desktop Shortcut” caused the error.

Fixing SCCM Task Sequence Failed With Error Code 0x80070002

Now we have identified the root cause from the previous step we can now implement a fix from the list below.

The error will be caused by an error in the command line within your sccm task sequence or application.

In my task sequence I can see there is a “Run Command Line” step with the command “del “%Public%\Desktop\*.lnk

google chrome task sequence step

SCCM Task Sequence

If you are getting the error in a SCCM task sequence follow these steps

  1. Log on to the ConfigMgr console
  2. go to \Software Library\Overview\Operating Systems\Task Sequences
  3. Right click on the task sequence that is giving the error and select edit
  4. Find the step that failed, In my example above it was the step “Remove Google Chrome Desktop Shortcut”
  5. In the command line add cmd /c at the start of the command line
  6. In my SCCM task sequence it looked like this cmd /c del “%Public%\Desktop\*.lnk”
    sccm task sequence
  7. Click ok to save the task sequence
  8. Try to build the machine again with the updated task sequence

SCCM Application

If you are getting the error when pushing out an SCCM application to a machine follow these steps.

  1. Log on to the client machine that failed to install the application and manually run the command that failed, in my case “del “%Public%\Desktop\*.lnk”
  2. Confirm the command ran with out errors
  3. If you did get an error, correct it and update the application within the Configmgr console
  4. Make sure the command line in the task sequence starts with cmd /c
  5. In my SCCM application I added cmd /c del “%Public%\Desktop\*.lnk” which resolved the issue (Shown below)
    sccm task sequence
  6. Click ok to save the application
  7. Highlight the application and click the “Deployment Types” tab and hit update content.  This will then re-distribute the application to the distribution points with the updated information.
  8. Deploy the application again

Other Fixes

The above 2 fixed should resolve the issue for you, but if it did not there are a few more things you can try to resolve this issue.

Confirm Contents Of Application

If the command line in the application has been configured correctly then it is possible that there is a problem with the files within the application, either the file is missing or has possible become corrupt.

To check this follow these steps.

  1. Log on to the ConfigMgr console
  2. go to \Software Library\Overview\Application Management\Applications\
  3. Right click on the required application and select properties
  4. Click deployment types tab
  5. Select application and hit edit
  6. Click programs tab
  7. Note down what is in “Installation Program”
  8. In the below example it is “Adobe_install.ps1”
    adobe application settings
  9. Now click on the content tab
  10. Copy the whole “Content Location” path
    sccm application content settings
  11. Open file explorer and go to the folder with the content in
  12. If the file from the “Installation Program” does not exist then you need to copy the file to here and re-distribute the application package
  13. Below you can see that the file “Adobe_install.ps1” does exist
    sccm application file contents
  14. Next we need to test if the file “Adobe_install.ps1” has become corrupted
  15. Copy all the install files to a test client
  16. Run the install using the command from the “Installation Program” field “Adobe_install.ps1” in my example
  17. If the file is corrupt re-create the file
  18. If it is not corrupted continue to the next fix

Confirm Content Status

If the application has not copied to a SCCM distribution point this can also cause issues.  To check your content has been copied to all SCCM DPs successfully follow these steps.

  1. Log on to the ConfigMgr console
  2. go to \Software Library\Overview\Application Management\Applications\
  3. Left click on your application
  4. Click Content Status under Related Objects, Bottom right
  5. View Status, bottom right
  6. Click on “In Progress” “Error” and “Unknown” tabs and confirm there is no packages showing in there
  7. If there are packages in them tabs take a look at the description to find out why they are stuck there

Delete and Re-Distribute The Application Package

Sometimes files can become corrupted when they are distributed to SCCM distribution points, usually because there was a network outage when the package was being copied.

To re-distribute a package follow these steps

  1. Log on to the ConfigMgr console
  2. go to \Software Library\Overview\Application Management\Applications\
  3. Left click on your application
  4. Click Content Status under Related Objects, Bottom right
  5. View Status, bottom right
  6. Note down all the SCCM distribution points the package has copied to
  7. go to \Administration\Overview\Site Configuration\Servers and Site System Roles
  8. Left click on each distribution point and perform the below steps to delete the package
  9. Highlight distribution Point system role
  10. Right click > Properties
  11. Click Content tab
  12. Highlight the required application
  13. Hit delete
  14. Once the application has been deleted from all distribution points wait an hour
  15. go to \Software Library\Overview\Application Management\Applications
  16. Right click on the application and select “Distribute Content”
  17. Wait for the content to re-distribute

Continue On Error (SCCM Task Sequence)

If you are getting the error 0x80070002 when running a task sequence you can configure “Continue On Error” and the task sequence will continue if the error appears.

This can be useful for the applications that install correctly but SCCM fails to detect them correctly.

To configure “Continue On Error” follow these steps.

  1. Log on to the ConfigMgr console
  2. go to \Software Library\Overview\Operating Systems\Task Sequences
  3. Right click on the required task sequence and select edit
  4. Now select the task sequence step that is causing the error
  5. Click on the options tab
  6. Tick the box “Continue On Error”
    sccm edit task sequence
  7. Click Ok
  8. Restart the task sequence

Set Network Access Account Permissions

Are you getting the error 0x80070002 on every SCCM package / application? If yes you will need to configure the network access account within the SCCM console.

To set the network access account permissions do the following

  1. Log on to the ConfigMgr console
  2. go to \Administration\Overview\Site Configuration\Sites
  3. Right click on your site server
  4. Select Configure Site Components then Software Distribution
  5. Select “Network Access Account” Tab
  6. Select “Specify the account that accesses network locations”
  7. Click the yellow star icon
  8. Add an account that has access to the SCCM site server files