Opens a Windows application by its executable name or full path.
This endpoint is also accessible via the open_application
tool in the Smooth Operator Agent Tools.
{ "appNameOrPath": "string" // The name of the application executable or full path }
Parameter | Type | Required | Description |
---|---|---|---|
appNameOrPath |
string | Yes | The name of the application executable (e.g., "notepad.exe") or the full path to the executable. |
{ "success": boolean, // Whether the operation was successful "message": "string" // A human-readable message indicating the result }
Note: All JSON keys in the response are in camelCase format.
import requests
import json
def open_application(app_name_or_path):
"""Opens an application on the Windows system.
Args:
app_name_or_path (str): The name of the application executable or full path
Returns:
dict: The response from the server
"""
url = "http://localhost:54321/tools-api/system/open-application"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer your_api_key_here"
}
data = {
"appNameOrPath": app_name_or_path
}
response = requests.post(url, headers=headers, json=data)
response.raise_for_status() # Raise an exception for HTTP errors
return response.json()
# Example usage
try:
# Open Notepad
result = open_application("notepad.exe")
print(f"Success: {result['success']}")
# You can also open applications using full paths
# result = open_application(r"C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE")
except Exception as e:
print(f"Error: {str(e)}")
import axios from 'axios';
async function openApplication(appNameOrPath: string): Promise {
/**
* Opens an application on the Windows system.
*
* @param appNameOrPath - The name of the application executable or full path
* @returns The response from the server
*/
const url = 'http://localhost:54321/tools-api/system/open-application';
const headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer your_api_key_here'
};
const data = {
appNameOrPath: appNameOrPath
};
try {
const response = await axios.post(url, data, { headers });
return response.data;
} catch (error) {
console.error('Error opening application:', error);
throw error;
}
}
// Example usage
(async () => {
try {
// Open Notepad
const result = await openApplication('notepad.exe');
console.log(`Success: ${result.success}`);
// You can also open applications using full paths
// const result = await openApplication('C:\\Program Files\\Microsoft Office\\root\\Office16\\EXCEL.EXE');
} catch (error) {
console.error('Failed to open application:', error);
}
})();
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
public class SmoothOperatorClient
{
private readonly HttpClient _httpClient;
private readonly string _baseUrl;
private readonly string _apiKey;
public SmoothOperatorClient(string baseUrl = "http://localhost:54321", string apiKey = "your_api_key_here")
{
_baseUrl = baseUrl;
_apiKey = apiKey;
_httpClient = new HttpClient();
}
///
/// Opens an application on the Windows system.
///
/// The name of the application executable or full path
/// The response from the server
public async Task OpenApplicationAsync(string appNameOrPath)
{
var request = new OpenApplicationRequest { AppNameOrPath = appNameOrPath };
return await SendRequestAsync("/tools-api/system/open-application", request);
}
private async Task SendRequestAsync(string endpoint, TRequest requestData)
{
var url = $"{_baseUrl}{endpoint}";
var request = new HttpRequestMessage(HttpMethod.Post, url);
// Add content
if (requestData != null)
{
string jsonContent = JsonSerializer.Serialize(requestData);
request.Content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
}
// Add authentication
request.Headers.Add("Authorization", $"Bearer {_apiKey}");
// Send the request
var response = await _httpClient.SendAsync(request);
// Check for success
if (!response.IsSuccessStatusCode)
{
string errorContent = await response.Content.ReadAsStringAsync();
throw new HttpRequestException($"Request to {endpoint} failed with status code {response.StatusCode}. Details: {errorContent}");
}
// Read and deserialize the response
string responseJson = await response.Content.ReadAsStringAsync();
var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true };
return JsonSerializer.Deserialize(responseJson, options);
}
}
public class OpenApplicationRequest
{
public string AppNameOrPath { get; set; }
}
public class SimpleResponse
{
public bool Success { get; set; }
public string Message { get; set; }
}
// Example usage
class Program
{
static async Task Main(string[] args)
{
var client = new SmoothOperatorClient();
try
{
// Open Notepad
var result = await client.OpenApplicationAsync("notepad.exe");
Console.WriteLine($"Success: {result.Success}");
// You can also open applications using full paths
// var result = await client.OpenApplicationAsync(@"C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE");
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}
{
"appNameOrPath": "notepad.exe"
}
{
"success": true,
"message": "Application opened."
}
{
"appNameOrPath": "C:\\Program Files\\Microsoft Office\\root\\Office16\\EXCEL.EXE"
}
{
"success": true,
"message": "Application opened."
}
{
"appNameOrPath": "nonexistentapp.exe"
}
{
"success": false,
"message": "Error opening application: The system cannot find the file specified"
}