Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Creating a batch file to run RDP and connect  (Read 101914 times)

0 Members and 1 Guest are viewing this topic.

Arrakis

    Topic Starter


    Greenhorn

    • Experience: Beginner
    • OS: Windows XP
    Creating a batch file to run RDP and connect
    « on: November 08, 2012, 03:42:38 AM »
    Hi, I am a complete novice with zero experience.

    I have daily tasks at work which require me to RDP to servers to check logs etc and was hoping I could create a batch file to launch on startup to save myself a bit of time.

    Any help would be greatly appreciated.

    So far all I have done is copy scripts I have found online but I'm struggling to find something suitable for my needs in this instance.  I have read some of the threads in this forum on similar requests but am baffled :/


    Thanks

    Adrian

    Arrakis

      Topic Starter


      Greenhorn

      • Experience: Beginner
      • OS: Windows XP
      Re: Creating a batch file to run RDP and connect
      « Reply #1 on: November 08, 2012, 03:46:02 AM »
      So far I have got this far..

      start /d "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories" mstsc.exe

      I'm such a n00b its almost embarrassing  :-\

      foxidrive



        Specialist
      • Thanked: 268
      • Experience: Experienced
      • OS: Windows 8
      Re: Creating a batch file to run RDP and connect
      « Reply #2 on: November 08, 2012, 03:47:36 AM »
      I don't RDP anywhere - what did you want to automate?

      What procedure do you use to RDP?

      Arrakis

        Topic Starter


        Greenhorn

        • Experience: Beginner
        • OS: Windows XP
        Re: Creating a batch file to run RDP and connect
        « Reply #3 on: November 08, 2012, 03:55:17 AM »
        Hi, did I not reply to your question above?

        Ideally I want to automate logon to an exchange server and run services.msc or test-servicehealth.  This check is one of my daily checks.

        foxidrive



          Specialist
        • Thanked: 268
        • Experience: Experienced
        • OS: Windows 8
        Re: Creating a batch file to run RDP and connect
        « Reply #4 on: November 08, 2012, 04:00:39 AM »
        http://windows.microsoft.com/en-AU/windows-vista/Use-command-line-parameters-with-Remote-Desktop-Connection

        You can automate the connection here.

        You might like to use PSEXEC to connect remotely and execute programs and get info, but not if you need GUI access.

        Arrakis

          Topic Starter


          Greenhorn

          • Experience: Beginner
          • OS: Windows XP
          Re: Creating a batch file to run RDP and connect
          « Reply #5 on: November 08, 2012, 04:19:51 AM »
          Not really sure what I need to add to make this work, there are no examples :/ I get further with what I've written already.  I need to automate the launch - connection - fill password field - connect.

          I dont know if this is even possible.

          Thanks for the link though.

          Arrakis

            Topic Starter


            Greenhorn

            • Experience: Beginner
            • OS: Windows XP
            Re: Creating a batch file to run RDP and connect
            « Reply #6 on: November 08, 2012, 04:37:24 AM »
            After further investigation I think a batch file maybe inappropriate for my needs, thoughts?

            foxidrive



              Specialist
            • Thanked: 268
            • Experience: Experienced
            • OS: Windows 8
            Re: Creating a batch file to run RDP and connect
            « Reply #7 on: November 08, 2012, 04:51:37 AM »
            The link shows that you need a connection file, and that will allow you to connect to the remote server with few keystrokes.

            You create/edit the connection file and write the batch file, call it R.BAT and put it in c:\Windows
            Then press Windows + R, type R and press enter.  You should be connected.

            The way I read it the link shows that with a connection file all you need is this:

            Code: [Select]
            @echo off
            mstsc "%userprofile%\desktop\server1.rdp"


            where you create the server1.rdp on your desktop.  You may be able to just double click the RDP file if the associations work.

            Arrakis

              Topic Starter


              Greenhorn

              • Experience: Beginner
              • OS: Windows XP
              Re: Creating a batch file to run RDP and connect
              « Reply #8 on: November 08, 2012, 07:35:07 AM »
              Well ive stumbled accross this online,

              mstsc /v: "IPADDRESSHERE" /w:640 /h:480

              Which gets me as far as putting my password in, any ideas for another line to add password and hit ok a few times?

              Arrakis

                Topic Starter


                Greenhorn

                • Experience: Beginner
                • OS: Windows XP
                Re: Creating a batch file to run RDP and connect
                « Reply #9 on: November 08, 2012, 08:15:38 AM »
                Right I just need a command to fill the password field then im there.  Anyone help out?

                gpl



                  Apprentice
                • Thanked: 27
                  Re: Creating a batch file to run RDP and connect
                  « Reply #10 on: November 08, 2012, 10:56:05 AM »
                  Even if you do get your script working, you will save yourself a huge amount of effort using this if you keep having to log into different (windows) servers - the Remote Desktop Connection Manager
                  http://www.microsoft.com/en-us/download/details.aspx?id=21101

                  Cybertek



                    Starter
                  • You Can Talk the Talk!,but Can You Walk the Walk?
                    • Certifications: List
                    • Computer: Specs
                    • Experience: Expert
                    • OS: Unknown
                    Re: Creating a batch file to run RDP and connect
                    « Reply #11 on: February 22, 2014, 07:15:49 AM »
                    PowerShell can create that script. Will create a temp connection to the target machine.
                    set-location \\targetmachine\c$
                    William H. Davis
                    IT Analyst
                    U.S. Army Cadet Command

                    clerkdon



                      Newbie

                      • Experience: Guru
                      • OS: Windows 7
                      Re: Creating a batch file to run RDP and connect
                      « Reply #12 on: August 21, 2014, 06:58:54 AM »
                      Did you try dropping down to "cmd" and typing "mstsc /?"  This will give you all of the commands that remote desktop will use/require.
                      I use batch files in the same way you do with a choice command to go through the remote servers

                      nickzoolander



                        Newbie

                        • Experience: Expert
                        • OS: Other
                        Re: Creating a batch file to run RDP and connect
                        « Reply #13 on: February 07, 2017, 08:19:01 AM »
                        SOLUTION:
                        Best way to go about this is open mstsc enter all your connection details then click save as, save to the desktop and your done.  :)

                        However if you wish to run mstsc as an administrator or for any other elevated commands create a notepad and enter:   mstsc /v:rdp.mycompany.com /console /admin
                        save as RDP.bat

                        patio

                        • Moderator


                        • Genius
                        • Maud' Dib
                        • Thanked: 1769
                          • Yes
                        • Experience: Beginner
                        • OS: Windows 7
                        Re: Creating a batch file to run RDP and connect
                        « Reply #14 on: February 07, 2017, 08:23:48 AM »
                        They left 1 1/2 Years ago...
                        " Anyone who goes to a psychiatrist should have his head examined. "