Solution to the problem of returning 0x1 when the Windows 2008 task plan fails to execute a bat script

Solution to the problem of returning 0x1 when the Windows 2008 task plan fails to execute a bat script

Test environment:

C:\>systeminfo | findstr /c:"OS Name"
OS Name: Microsoft Windows Server 2008 R2 Enterprise

Many people encounter this problem when creating a task schedule to execute a bat file in Windows 2008: the status code returned after the task schedule is executed is 0x1 instead of the normal 0x0

I was also stuck with this problem today and spent almost a day troubleshooting it. Everything works fine when executing the bat script alone, and there is no problem executing the bat script in the Windows 2003 task schedule, but it does not work as long as it is placed in the Windows 2008 task schedule. After searching on domestic and foreign websites, I finally collected all the precautions. The steps are summarized as follows:

1. Confirm that the password of the user who wants to execute the task plan has not expired. If conditions permit, you can set the password to never expire to avoid unnecessary trouble.

The Chinese system has a password that never expires option

2. Open the Task Manager, right-click Task Scheduler Library, and select Create Task. Do not select Create Basic Task here.

3. In the General tab, select Run whether user is logged on or not, check Run with highest privileges, and then select Windows Server 2003 from the drop-down list. Do not select Windows Server 2008.

The Chinese system corresponds to the following figure

4. There is nothing special in the Triggers tab. Just set the execution time according to your needs.

5. In the Actions tab, fill in the script name in the Program/script input box. Do not include the path here. In the Start in input box, fill in the path where the script is located. Do not add quotation marks here.

6. Add a line at the end of the bat script:

Click (here) to collapse or expand

exit /b 0

If you do not explicitly specify an exit code, Task Scheduler will assume that the script execution has failed.

Versions prior to Window Server 2012 do not require a path to execute scheduled tasks

The version after Windows Server 2012 needs to set the path to execute the scheduled task. The batch program can be run normally by double-clicking it, but the error code 0x1 is not reported when it is put into the Windows scheduled task.

Cause of the error: The batch script in the program and script has a directory structure, but the path to the directory where the batch script is located is not configured at the start

The above is the detailed solution to the problem that the Windows 2008 task plan fails to execute the bat script and returns 0x1. For more information about win2008 bat script fails to return 0x1, please pay attention to other related articles on 123WORDPRESS.COM!

You may also be interested in:
  • Solution to the problem of batch processing failure in Windows 2008 r2 task scheduler

<<:  Summary of Mysql update multi-table joint update method

>>:  This article takes you into the world of js data types and data structures

Recommend

MySql 5.6.36 64-bit green version installation graphic tutorial

There are many articles about MySQL installation ...

MySQL learning record: bloody incident caused by KEY partition

Demand background Part of the data in the busines...

JavaScript implements mouse drag to adjust div size

This article shares the specific code of JavaScri...

MySQL trigger syntax and application examples

This article uses examples to illustrate the synt...

How to install Apache service in Linux operating system

Download link: Operating Environment CentOS 7.6 i...

Summary of webpack's mobile adaptation solution

Table of contents rem vw Adapt to third-party UI ...

Detailed explanation of script debugging mechanism in bash

Run the script in debug mode You can run the enti...

Several common methods of CSS equal height layout

Equal height layout Refers to the layout of child...

JavaScript BOM location object + navigator object + history object

Table of contents 1. Location Object 1. URL 2. Pr...

Vue data two-way binding implementation method

Table of contents 1. Introduction 2. Code Impleme...

How to reduce the memory and CPU usage of web pages

<br />Some web pages may not look large but ...

Detailed explanation of the implementation of shared modules in Angular projects

Table of contents 1. Shared CommonModule 2. Share...

Common shell script commands and related knowledge under Linux

Table of contents 1. Some points to remember 1. V...

JS implements random generation of verification code

This article example shares the specific code of ...