Search This Blog

Saturday, September 25, 2010

Generate RDP Files for Remote Desktop

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

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

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]

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
user = "user1"
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)
WshShell.Run("mstsc " & outputfile), 1, true

No comments: