Search This Blog

Saturday, September 25, 2010

Generate RDP Files for Remote Desktop

Barebones RDP File (3 lines)
full address:s:
username:s:
password 51:b:

Group Policy: Run his CMD script at beginning of user login to generate the RDP file for Remote Desktop.

VBS:
Set oExec = WshShell.Exec("cryptRDP5.exe password")
pwdhash = oExec.StdOut.readall

To prevent dialog box from coming up, decimal 76

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\LocalDevices]
"XXX.XXX.XXX"=dword:0000004c

Script below will encrypt the password into the RDP code, generate a RDP file on the desktop, and run the RDP file. Run script at user login.
-----

Set WshShell = CreateObject("WScript.Shell")
computername = WshShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
Select Case computername
Case "COMPUTER1"
user = "user1"
Case "COMPUTER2"
user = "user2"
End Select
Set oExec = WshShell.Exec("\\server\cryptRDP5.exe password")
pwdhash = oExec.StdOut.readall
outputfile = WshShell.ExpandEnvironmentStrings("%USERPROFILE%") & "\Desktop\Remote.rdp"
Set fso = CreateObject("Scripting.FileSystemObject")
Set fsofile = fso.CreateTextFile(outputfile)
fsofile.WriteLine("full address:s:remoteaddress")
fsofile.WriteLine("username:s:" & user)
fsofile.WriteLine("password 51:b:" & pwdhash)
fsofile.Close
WshShell.Run("mstsc " & outputfile), 1, true

No comments: