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
- Run the task sequence
- Press F8 and this will bring up the command prompt
- Wait for the error to appear (As shown below)
- 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
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”
SCCM Task Sequence
If you are getting the error in a SCCM task sequence follow these steps
- Log on to the ConfigMgr console
- go to \Software Library\Overview\Operating Systems\Task Sequences
- Right click on the task sequence that is giving the error and select edit
- Find the step that failed, In my example above it was the step “Remove Google Chrome Desktop Shortcut”
- In the command line add cmd /c at the start of the command line
- In my SCCM task sequence it looked like this cmd /c del “%Public%\Desktop\*.lnk”
- Click ok to save the task sequence
- 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.
- 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”
- Confirm the command ran with out errors
- If you did get an error, correct it and update the application within the Configmgr console
- Make sure the command line in the task sequence starts with cmd /c
- In my SCCM application I added cmd /c del “%Public%\Desktop\*.lnk” which resolved the issue (Shown below)
- Click ok to save the application
- 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.
- 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.
- Log on to the ConfigMgr console
- go to \Software Library\Overview\Application Management\Applications\
- Right click on the required application and select properties
- Click deployment types tab
- Select application and hit edit
- Click programs tab
- Note down what is in “Installation Program”
- In the below example it is “Adobe_install.ps1”
- Now click on the content tab
- Copy the whole “Content Location” path
- Open file explorer and go to the folder with the content in
- 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
- Below you can see that the file “Adobe_install.ps1” does exist
- Next we need to test if the file “Adobe_install.ps1” has become corrupted
- Copy all the install files to a test client
- Run the install using the command from the “Installation Program” field “Adobe_install.ps1” in my example
- If the file is corrupt re-create the file
- 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.
- Log on to the ConfigMgr console
- go to \Software Library\Overview\Application Management\Applications\
- Left click on your application
- Click Content Status under Related Objects, Bottom right
- View Status, bottom right
- Click on “In Progress” “Error” and “Unknown” tabs and confirm there is no packages showing in there
- 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
- Log on to the ConfigMgr console
- go to \Software Library\Overview\Application Management\Applications\
- Left click on your application
- Click Content Status under Related Objects, Bottom right
- View Status, bottom right
- Note down all the SCCM distribution points the package has copied to
- go to \Administration\Overview\Site Configuration\Servers and Site System Roles
- Left click on each distribution point and perform the below steps to delete the package
- Highlight distribution Point system role
- Right click > Properties
- Click Content tab
- Highlight the required application
- Hit delete
- Once the application has been deleted from all distribution points wait an hour
- go to \Software Library\Overview\Application Management\Applications
- Right click on the application and select “Distribute Content”
- 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.
- Log on to the ConfigMgr console
- go to \Software Library\Overview\Operating Systems\Task Sequences
- Right click on the required task sequence and select edit
- Now select the task sequence step that is causing the error
- Click on the options tab
- Tick the box “Continue On Error”
- Click Ok
- 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
- Log on to the ConfigMgr console
- go to \Administration\Overview\Site Configuration\Sites
- Right click on your site server
- Select Configure Site Components then Software Distribution
- Select “Network Access Account” Tab
- Select “Specify the account that accesses network locations”
- Click the yellow star icon
- Add an account that has access to the SCCM site server files
Hello, I am the owner of this site. I have 25+ years experience of IT. Check us out on the below social platforms.