Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ members = [
"bindings/python",
"bindings/nodejs",
"terminator-mcp-agent",
"terminator-workflow-recorder",
"terminator-workflow-recorder", "test-launch",
]


Expand Down
2 changes: 2 additions & 0 deletions bindings/nodejs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ napi = { version = "2.12.2", default-features = false, features = [
"tokio_rt",
] }
napi-derive = "2.12.2"


terminator = { workspace = true }
tracing-subscriber = { workspace = true }
serde_json = "1.0"
Expand Down
51 changes: 51 additions & 0 deletions bindings/nodejs/src/session0_launcherold.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
use windows::{
Win32::System::Threading::{
CreateProcessAsUserW, PROCESS_INFORMATION, STARTUPINFOW,
},
Win32::Security::Authentication::Identity::WTSQueryUserToken,
Win32::System::RemoteDesktop::WTSGetActiveConsoleSessionId,
Win32::Foundation::{CloseHandle, HANDLE},
};

use std::ptr::null_mut;

pub fn launch_in_session0(app_name: &str) {
unsafe {
let session_id = WTSGetActiveConsoleSessionId();

let mut user_token: HANDLE = HANDLE::default();
let result = WTSQueryUserToken(session_id, &mut user_token);

if !result.as_bool() {
println!("❌ Failed to get user token.");
return;
}

let mut startup_info = STARTUPINFOW::default();
let mut process_info = PROCESS_INFORMATION::default();

let app: Vec<u16> = format!("{}\0", app_name).encode_utf16().collect();

let created = CreateProcessAsUserW(
user_token,
None,
&app,
None,
None,
false,
Default::default(),
None,
None,
&mut startup_info,
&mut process_info,
);

if created.as_bool() {
println!("βœ… App launched in Session 0.");
} else {
println!("❌ Failed to launch app in Session 0.");
}

CloseHandle(user_token);
}
}
6 changes: 6 additions & 0 deletions terminator-workflow-recorder/examples/launch_demo.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use terminator_workflow_recorder::session0_launcher;


fn main() {
session0_launcher::launch_in_session0("notepad.exe");
}
4 changes: 4 additions & 0 deletions terminator-workflow-recorder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
mod error;
mod events;
mod recorder;
pub mod session0_launcher;


pub use error::*;
pub use events::{
Expand All @@ -19,6 +21,8 @@ pub use events::{
TextInputCompletedEvent, TextInputMethod, TextSelectionEvent, WorkflowEvent,
};
pub use recorder::*;
pub use session0_launcher::*;


#[cfg(target_os = "windows")]
pub mod structs {
Expand Down
6 changes: 6 additions & 0 deletions terminator-workflow-recorder/src/session0_launcher.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use std::process::Command;

pub fn launch_in_session0(app: &str) {
println!("Launching '{}' in Session 0...", app);
let _ = Command::new(app).spawn();
}
8 changes: 8 additions & 0 deletions test-launch/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "test-launch"
version.workspace = true
edition.workspace = true
license-file.workspace = true

[dependencies]
windows = "0.56.0"
7 changes: 7 additions & 0 deletions test-launch/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mod session0_launcher;

fn main() {
session0_launcher::launch_in_session0("notepad.exe");
}