Hi @MIPAKTEH_1 , Welcome to Microsoft Q&A,
If you can connect correctly.
You can use the System.Diagnostics.Process
class to start the calculator.
private void Form1_Load(object sender, EventArgs e)
{
ConnectionOptions options = new ConnectionOptions();
options.Username = "your_remote_username";
options.Password = "your_remote_password";
options.Authority = "ntlmdomain:your_domain";
string remoteComputer = "192.168.0.199"; // Replace with the IP address or name of your remote computer
ManagementScope scope = new ManagementScope($"\\\\{remoteComputer}\\root\\cimv2", options);
scope.Options.EnablePrivileges = true;
ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_Process");
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query))
{
ManagementClass processClass = new ManagementClass(scope, new ManagementPath("Win32_Process"), new ObjectGetOptions());
ManagementBaseObject inParams = processClass.GetMethodParameters("Create");
//Set the process path to be started
inParams["CommandLine"] = "calc.exe";
//Start the calculator process
ManagementBaseObject outParams = processClass.InvokeMethod("Create", inParams, null);
// Get process ID
uint processId = (uint)outParams["processId"];
Console.WriteLine($"Calculator process started with Process ID: {processId}");
}
}
You need to make sure the exe path is correct. Also make sure to replace your_remote_username, your_remote_password and your_domain with your actual credentials and domain name of your remote computer, and replace remoteComputer with the IP address or name of the remote computer you want to connect to.
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.