-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrd.bat
38 lines (32 loc) · 944 Bytes
/
rd.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
@ECHO OFF
REM rd.bat
REM Purpose: Opens a remote desktop connection by filename.rdp, IP address, or computer name; Opens remote desktop window if no argument given
REM Usage: rd ([filename]|[IP]|[computername])
REM Examples:
REM rd
REM rd filename
REM rd 127.0.0.1
REM rd LOCALHOST
REM Notes:
REM * Assumes filename, IP, or computer name is the first argument
REM * Assumes directory is the script's directory
SET FILENAME=%1
SET DIRECTORY=%~dp0
SET TARGET=%1.rdp
REM If "filename.rdp" exists, open it
IF EXIST %DIRECTORY%%TARGET% GOTO :OPENFILE
REM If argument was given, open remote desktop with it (assumes IP or computer name)
IF NOT '%1'=='' GOTO :OPENARGUMENT
REM If no argument, open remote desktop window (mstsc.exe)
IF '%1'=='' GOTO :OPENWINDOW
:OPENFILE
START "" /D %DIRECTORY% %TARGET%
GOTO :END
:OPENARGUMENT
%WINDIR%\system32\mstsc.exe /v:%1
GOTO :END
:OPENWINDOW
%WINDIR%\system32\mstsc.exe
GOTO :END
:END
EXIT