Last active
February 17, 2021 06:40
-
-
Save flow4u/f286479e78a1146369cc6ea4399bb5ec to your computer and use it in GitHub Desktop.
.bat: MyDRE easy open session with 2 monitors (mutlimonitor is restricted to 2), also works with 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: This script for Windows make it easier to run RDP files on Windows | |
:: After downloading the RDP, run this script | |
:: It picks up the latest RDP-file from downloads, copies it to MyDRE.RDP | |
:: Adds a few lines to the RDP for magic (customize in the section: CUSTOM | |
:: Deletes the downloaded RDP file to prevent clutter in your Downloads | |
:: Runs the script | |
:: CUSTOMIZATION | |
:: Par3: select the monintors to be used, make sure these monitors are adjecent | |
:: E.g.: 0,1 = Use Monitor 0 and 1 | |
SET Par1=span monitors:i:1 | |
SET Par2=use multimon:i:1 | |
SET Par3=selectedmonitors:s:0,1 | |
:: Finds the latest RDP-file in downloads and ends script if no RDP-file is present | |
SET Location=\Downloads\ | |
SET SearchFor=*.rdp | |
SET SearchString="%UserProfile%%Location%%SearchFor%" | |
FOR /F "eol=| delims=" %%I IN ('DIR %SearchString% /A-D /B /O-D /TW 2^>nul') DO ( | |
SET NewestFile=%%I | |
GOTO FoundFile | |
) | |
ECHO No *.rdp file found! | |
GOTO :EOF | |
:: Skips adding lines to MyDRE.RDP if MyDRE.RDP is the latest RDP-file | |
:: Copies the latest RDP-file to MyDRE.RDP, removes the latest RDP-file | |
:: Adds multimonitor support the MyDRE.RDP | |
:FoundFile | |
IF "%NewestFile%"==MyDRE.rdp GOTO OpenRDP | |
ECHO Newest *.rdp file is: %NewestFile% | |
SET Source="%UserProfile%%Location%%NewestFile%" | |
SET TargetFile=MyDRE.rdp | |
SET Target="%UserProfile%%Location%%TargetFile% | |
COPY %Source% %Target% | |
ECHO.>> %Target% | |
ECHO %Par1% >> %Target% | |
ECHO %Par2% >> %Target% | |
ECHO %Par3% >> %Target% | |
DEL %Source% | |
:: Opens MyDRE.RDP | |
:OpenRDP | |
start mstsc.exe %Target% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use (assuming you put a shortcut on Windows Taskbar):
You can download a nice icon: app.ico.
Alternatively, download the app.zip. Extract it in c:\users\public\shortcuts and drag the MyDRE - Shortcut to Windows task bar and you're good to go.
Some organizations block zips with extensions, download this zip and read the instructions.
A small modification, already in the zip, of the shortcut was needed in order to be able to put it on the Windows Taskbar:
The shortcut has:
Target: C:\Windows\System32\cmd.exe /c "C:\Users\Public\Shortcuts\MyDRE.bat"
Start in: C:\Users\Public\Desktop
Change icon: %SystemDrive%\Users\Public\Shortcuts\app.ico
A Python version with the same functionality can be found here.
A .bat version with the same functionality can be found here