I have the adminpak.msi installed so that I can use the Remote Desktop MMC to connect to all of my servers. As I add a server, it goes to the bottom of the list of available servers. I can't find out how to re-order them into more logical groupings, or at least alphabetical. Any ideas?
I found a solution. Looks like the msc file has an encrypted area that is just not accessible. So I found a script from Brett Clarke at http://twistingthewick.org. I've modified it a bit to add structure and login information. It uses our old friend SendKeys.
You need to create a CSV with:
server-name-or-ip,description,userid,domain
one per line for each server. You'll have to sort this the way you want it.
You can also add a line to break things up into separate ad-ins using the syntax:
---,some-name,,
some-name is not used; each section is named Remote Desktops. If someone can figure out how to change the name, please let me know.
For now, this seems to work, and allows re-building any time you need to add a server. You might need to tweak the delays on your system.
Oh, and this probably won't work on Vista or Windows 7 as the SendKeys method has been disabled for security purposes.
I like to share drives, so this script checks that box. You can modify it to do pretty much anything you need.
First, though, you need to start out with a blank tsmmc.msc file. Open MMC and add a Remote Desktops snap-in. The script wants it called blanktsmmc.msc in c:\Projects\SortMmc. Of course, you'll need to have the Windows Admin Pak loaded.
Script is utilitarian, designed for speed of coding, not elegance. If you make improvements, please share.
And I'm new here. If you like this, I could use some Karma!
' CreateTSMMC.vbs
' Script to re-create tsmmc entries in order
' Author: Brett Clarke http://twistingthewick.org
' Version: 0.1 – 21/06/2007
'
' Updated by Brian Travis, adding login and drive info
' Version: 0.2 - 2009-08-26
'———————————————————————
'Declare some variables
Option Explicit
Const ForReading = 1
Dim objShell, objFSO, objFileCopy, objDictionary, objTextFile
Dim strBlankMMC, strWorkingMMC, strTemplate, strNextLine
Dim arrRDPList
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objDictionary = CreateObject("Scripting.Dictionary")
strBlankMMC = "c:\Projects\SortTsmmc\blanktsmmc.msc"
strWorkingMMC = "c:\windows\system32\tsmmc.msc"
strTemplate = "c:\Projects\SortTsmmc\tsmmc.csv"
Set objFileCopy = objFSO.GetFile(strBlankMMC)
Set objTextFile = objFSO.OpenTextFile (strTemplate, ForReading)
' copy the blank template file over the working file
objFileCopy.Copy (strWorkingMMC)
' start up MMC
objShell.Run "c:\windows\system32\tsmmc.msc"
' wait for the app to start
Wscript.Sleep 1500
' get to the plugin
objShell.SendKeys "{DOWN}"
' read the CSV file, and parse the entries into the MMC session
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.ReadLine
arrRDPList = Split(strNextLine , ",")
if arrRDPList(0) = "---" then
' create a new group
objShell.SendKeys "%f"
objShell.SendKeys "m"
objShell.SendKeys "%d"
objShell.SendKeys "rem"
objShell.SendKeys "%a"
objShell.SendKeys "%c"
objShell.SendKeys "{ENTER}"
objShell.SendKeys "{END}"
else
objShell.SendKeys "+{F10}"
objShell.SendKeys "A"
objShell.SendKeys arrRDPList(0)
objShell.SendKeys "{TAB}"
Wscript.Sleep 100
objShell.SendKeys "{TAB}"
Wscript.Sleep 100
objShell.SendKeys arrRDPList(1)
Wscript.Sleep 100
objShell.SendKeys "{TAB}"
Wscript.Sleep 100
objShell.SendKeys "{TAB}"
objShell.SendKeys arrRDPList(2)
Wscript.Sleep 100
objShell.SendKeys "{TAB}"
objShell.SendKeys "{TAB}"
objShell.SendKeys arrRDPList(3)
objShell.SendKeys "{TAB}"
objShell.SendKeys " "
objShell.SendKeys "{ENTER}"
Wscript.Sleep 100
' turn on drive sharing
Wscript.Sleep 100
objShell.SendKeys "{TAB}"
objShell.SendKeys "{END}"
objShell.SendKeys "+{F10}"
objShell.SendKeys "r"
objShell.SendKeys "+{TAB}"
objShell.SendKeys "{RIGHT}"
objShell.SendKeys "{RIGHT}"
objShell.SendKeys "{TAB}"
objShell.SendKeys "{TAB}"
objShell.SendKeys " "
objShell.SendKeys "{ENTER}"
' get back to left column
objShell.SendKeys "+{TAB}"
end if
Loop
objShell.SendKeys "^s"
WScript.Quit
Nice update, Brian. I was looking in to having seperate sections with different names as well (AD, Exchange, etc...), but I don't think there is any way to do it via scripting. As far as I can tell, the way to do it is to create a new MMC snap-in (using some SDK) based on the existing Remote Desktops snap-in, named whatever you want the section to be called. Some good googling should get you headed in the right direction.
Cheers Brett