Automate Your Workflow: Inspire Batch Mode Processing with Windows Task Scheduler
The Windows Task Scheduler is a powerful and versatile tool integrated into the Microsoft Windows operating system.
It allows users to automate the execution of tasks at specific times or in response to particular system events. This
capability is essential for both personal and enterprise-level computing, where routine tasks need to be performed
consistently without manual intervention.
Inspire batch mode can leverage this functionality and can do automated task without user intervention.
Below are the detailed steps how to setup a Windows Task Scheduler for a inspire batch mode.
Step 1: Prepare Your Batch File
- Create the Batch File:
- Open Notepad or any text editor.
- Write the commands you want to execute.
For example: C:/Program Files/Altair/2024/hwx/bin/win64/ExecWinEnvInsp.exe -cfg -b -p Inspire -ex hwx.exe -f C:/Scripts/my_analysis_script.py
my_analysis_script.py file is attached in this blog for reference. - Save the file with a .bat extension (e.g., backup.bat).
- Refer Unleashing the Power of Inspire Python API and Batch Mode Processing - Inspire - Altair Products - Altair Community blog for more details on how to setting up a bat file and python script for inspire batch mode.
- Test the Batch File:
- Before scheduling, double-click the .bat file to ensure it runs correctly.
Step 2: Open Task Scheduler
- Access Task Scheduler:
- Press Win + S and type "Task Scheduler" in the search bar.
- Click on "Task Scheduler" in the results to open it.
Step 3: Create a New Task
- Create Task:
- In the Task Scheduler, click on "Create Task" in the right-hand pane under "Actions."
- General Tab:
- Name: Enter a name for your task (e.g., Backup Task).
- Description: (Optional) Provide a description of the task.
- Security Options:
- Choose "Run only when user is logged on" if the task does not need to run while the user is logged off.
- Choose "Run whether user is logged on or not" if the task should run in the background, even when logged off. (You may need to enter your credentials if you select this.)
- Optionally, check "Run with highest privileges" if your task requires administrator rights.
Step 4: Set the Trigger
- Triggers Tab:
- Click on "New..." to create a new trigger.
- Begin the task: Choose when you want the task to start (e.g., "On a schedule").
- Set the specifics of the trigger:
- One time: For a one-time execution.
- Daily: For daily execution.
- Weekly: For weekly execution.
- Monthly: For monthly execution.
- Advanced settings: Configure additional options such as delays, repeat frequency, or expiration.
- Click "OK" to save the trigger.
Step 5: Set the Action
- Actions Tab:
- Click on "New..." to create a new action.
- Action: Ensure "Start a program" is selected.
- Program/script: Click "Browse..." and navigate to your .bat file.
- Add arguments (optional): If your batch file requires any arguments, you can enter them here.
- Start in (optional): Specify the working directory for the batch file if necessary (usually the folder where the batch file resides).
- Click "OK" to save the action.
Step 6: Configure Additional Settings (Optional)
- Conditions Tab:
- Configure conditions under which the task will run, such as only when the computer is idle, or only when it’s on AC power.
- Check or uncheck options based on your needs.
- Settings Tab:
- Configure settings like allowing the task to run on demand, stopping the task if it runs too long, or forcing it to start if a scheduled time is missed.
Step 7: Finalize and Test
- Review and Save:
- Review all settings to ensure everything is correct.
- Click "OK" to save the task.
- If you chose "Run whether user is logged on or not," you might be prompted to enter your Windows credentials.
- Test the Task:
- In the Task Scheduler library, find your task.
- Right-click on it and select "Run" to test if it executes as expected.
- Check for Errors:
- If the task fails, check the "History" tab of the task to see what went wrong.
- Verify that the batch file works manually and that all paths are correct.
Step 8: Monitor and Manage the Task
- Monitor the Task:
- Periodically check the Task Scheduler to ensure the task is running as expected.
- Edit or Delete the Task:
- To edit the task, right-click it and select "Properties."
- To delete the task, right-click it and select "Delete."
This step-by-step guide should help you successfully create and manage a Windows Scheduled Task that runs a .bat file.
Happy scripting!