Showing posts with label Windows. Show all posts
Showing posts with label Windows. Show all posts

Thursday, June 5, 2025

Windows: Using Operating System Scheduler

  1. Create a MATLAB Script: Save your MATLAB code in a .m file, e.g., myScript.m:
  2. 1
    2
    3
    disp('Running my daily task at 6 PM!');
    % Your code here
    exit; % Close MATLAB after execution
    
  3. Create a Batch File: Create a .bat file (e.g., run_matlab_script.bat) to run the script in MATLAB:
  4. 1
    "C:\Program Files\MATLAB\R2023a\bin\matlab.exe" -batch "run('C:\path\to\myScript.m')"
    • Replace R2023a with your MATLAB version.
    • Replace C:\path\to\myScript.m with the full path to your script.
  5. Schedule with Windows Task Scheduler:
    • Open Task Scheduler (search for it in Windows).
    • Click Create Task (not Basic Task for daily scheduling).
    • General Tab:
      • Name the task (e.g., "Run MATLAB Daily").
      • Check "Run whether user is logged on or not" for reliability.
    • Triggers Tab:
      • Click New → Set trigger to Daily at 6:00 PM.
      • Ensure "Enabled" is checked.
    • Actions Tab:
      • Click New → Action: Start a Program.
      • Browse to your .bat file (e.g., C:\path\to\run_matlab_script.bat).
    • Conditions/Settings:
      • Optional: Set conditions like "Start only if computer is on AC power."
      • Save the task, entering your user credentials if prompted.
  6. Test:
    • Right-click the task in Task Scheduler and select Run to verify it executes correctly.

Friday, September 22, 2017

CMD控制台中文乱码的解决方法

默认情况下,Windows的CMD控制台常常不支持中文显示,看上去是一些乱码,这就很不方便了。
Fig. 1
解决之道是修改CMD的文件编码类型,新建一个名为cmd.reg的文件,内容如下:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
Windows Registry Editor Version 5.00




[HKEY_CURRENT_USER\Console\%SystemRoot%_system32_cmd.exe]

"CodePage"=dword:0000fde9

"FontFamily"=dword:00000036

"FontWeight"=dword:00000190

"FaceName"="Consolas"

"ScreenBufferSize"=dword:232900d2

"WindowSize"=dword:002b00d2
新建之后,双击该文件运行。重新启动CMD,此时它支持中文如Fig.2。
Fig. 2

Reference