Pages

Friday, October 11, 2013

Create multiple RDP files for different servers Batch File

Creating mass/multiple RDP files just using a simple batch script.

Copy the content below in a notepad file and save it as CreateRDP.bat

@ echo off
for /f "tokens=1,2* delims=," %%h in (servers.csv) do (echo full address:s:%%i >>%%h.txt
type template.txt >> %%h.txt
ren %%h.txt %%h.rdp
echo RDP File created successfully for server %%h
)


In an excel sheet put server names in column A and IP address in B and save it as csv, (do not put any header line)
It will look like this when opened in notepad:

server1,10.10.10.10
server2,10.10.10.11


Create a notepad file and paste the content below and save it as template.txt

screen mode id:i:1
desktopwidth:i:1280
desktopheight:i:800
audiomode:i:2
authentication level:i:0
autoreconnection enabled:i:1
bitmapcachepersistenable:i:1
compression:i:1
disable cursor setting:i:0
disable full window drag:i:1
disable menu anims:i:1
disable themes:i:1
disable wallpaper:i:1
displayconnectionbar:i:1
keyboardhook:i:2
redirectclipboard:i:1
redirectcomports:i:0
redirectdrives:i:0
redirectprinters:i:0
redirectsmartcards:i:0
session bpp:i:16
prompt for credentials:i:0
promptcredentialonce:i:1
winposstr:s:0,3,0,0,800,600
allow desktop composition:i:0
allow font smoothing:i:0
redirectposdevices:i:0
drivestoredirect:s:
negotiate security layer:i:1
remoteapplicationmode:i:0
alternate shell:s:
shell working directory:s:
gatewayhostname:s:
gatewayusagemethod:i:4
gatewaycredentialssource:i:4
gatewayprofileusagemethod:i:0


keep all three files created in above steps in one folder, (createrdp.bat, servers.csv & template.txt).
double clicking the createrdp batch file will start creating RDP files for the servers mentioned in csv file.

Please post for any query/feedback/suggestion.






2 comments:

  1. Correction:

    @ echo off
    for /f "tokens=1,2* delims=," %%h in (servers.csv) do (echo full address:s:%%i >>%%h.txt
    type template.txt >> %%h.txt
    ren "%%h.txt" "%%h.rdp"
    echo RDP File created successfully for server %%h
    )

    otherwise you going get "The syntax of the command is incorrect." error

    ReplyDelete
    Replies
    1. Thanks Yakuza. How do I add username s too as a third column to bulk write RDP in computer name , username?

      Delete