Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6539875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:54:40+00:00 2026-05-25T10:54:40+00:00

I need a script that can run an RDP file at login, and keep

  • 0

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(); `
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:54:41+00:00Added an answer on May 25, 2026 at 10:54 am

    Here is the code you need:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading;
    using System.Diagnostics;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("Please don't close this box!");
                RDP();
                while (true)
                {
                    if (Process.GetProcessesByName("mstsc").Length == 0)
                    {
                        RDP();
                        Thread.Sleep(1000);
                    }
                }
            }
    
            private static void RDP()
            {
                Process rdp = new Process();
                rdp.StartInfo = new ProcessStartInfo("C:\\RDP\\rdp.rdp");
                rdp.Start();
            }
        }
    }
    

    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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a simple proxy PHP function/script that can download a file from a
I need to run a Bash script that can echo a 300 lines of
I need to make a proxy script that can access a page hidden behind
I need to modify a php search script so that it can handle multiple
I need a script that inserts a number at some point into a file
I need to make a script that will take files from a user and
What I want is a function I can run on user input that will
I need to write a script that disables SQL Server Express 2008 from running.
I need to parse a file that has the following formatted data and get
I need a script that I can put on any page in an application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.