I need a script that can run an RDP file at login, and keep running..
Wait until the user has logged off from the remote session, and relaunch the RDP file.
Im thinking look in tasklist for mstsc.exe and use an IF statement if it is or is not running?
Any help would be greatly appreciated!
EDIT: Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Diagnostics;
namespace RDPv1
static void Main(string[] args)
{
RDP();
while(true)
{
foreach (Process clsProcess in Process.GetProcesses())
{
if (!clsProcess.ProcessName.Contains("mstsc.exe"))
{
RDP();
break;
}
}
Thread.sleep(300);///Use any value which is confortable with you're request
}
}
private static void RDP()
{
Process rdp = new Process();
rdp.StartInfo = new ProcessStartInfo(@"C:\RDP.rdp");
rdp.Start(); `
Here is the code you need:
Basically it launches the rdp and then goes into an infinite loop checking if the process is running, if it isn’t then it launches it again.
To put it into VS just open VS C#, start a new Console Application and paste the above in. Then press the green triangle and it will run the program, to find the EXE of it, it’s usually in Documents\Visual Studio\Projects\Your Project Name\Your Project Name\bin\Debug
Credit to Cody for helping with this script earlier