Skip to content

gmh5225/schtask

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Windows Task Scheduler Rust Implementation

This project is a Rust implementation of the Windows Task Scheduler functionality, specifically focusing on creating tasks that execute when a user logs on. It is based on the Microsoft Windows Task Scheduler Logon Trigger Example.

Features

  • Create scheduled tasks that run when a user logs on
  • Support for command-line arguments when running tasks
  • Dynamically find Task Scheduler GUIDs from the Windows Registry
  • Support for custom executable paths
  • Automatic cleanup of existing tasks with the same name
  • Proper COM initialization and cleanup
  • Error handling and reporting

Dependencies

The project uses the following main dependencies:

  • winapi - For Windows API bindings
  • winreg - For Windows Registry access

Usage

Add the following to your Cargo.toml

[dependencies]
schtask = { git = "https://github.com/Teach2Breach/schtask.git", branch = "main" }

Use in your project:

use schtask::create_task;

fn main() {
    // Create a task that runs notepad.exe when the user logs on
    let result = create_task("MyTask", "C:\\Windows\\System32\\notepad.exe", None);
    println!("{}", result);

    // Create a task with command-line arguments
    let result = create_task(
        "MyTaskWithArgs",
        "C:\\Windows\\System32\\notepad.exe",
        Some("C:\\Windows\\System32\\drivers\\etc\\hosts")
    );
    println!("{}", result);
}

Implementation Details

The implementation follows the Windows Task Scheduler COM interface pattern:

  1. Initialize COM and security settings
  2. Create an instance of the Task Service
  3. Get the root task folder
  4. Create a new task definition
  5. Configure task settings and registration info
  6. Add a logon trigger
  7. Set up the executable action with optional arguments
  8. Register the task

Security Considerations

  • The task is created with the current user's credentials
  • Tasks are created with interactive token logon type
  • The implementation includes proper COM security initialization

About

Rust implementation, creating a scheduled task programmatically with user logon trigger.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Rust 100.0%