Não tenho certeza se os botões / campos / opções (ou outros) foram alterados na minha versão das áreas de trabalho remotas (v5.2.3790.0), mas se alguém está tendo problemas para fazer com que a v0.1 ou v0.2 crie os RDs, aqui está uma v0.3 com minhas pequenas alterações que finalmente conseguiram automatizar corretamente na minha máquina XP. Espero que isso ajude.
PREREQS (Veja as postagens v0.1, v0.2 para detalhes sobre como fazer esses arquivos):
Exemplo de arquivo CSV dividido em seções:
---[AGENTS]---,,,
agent-pc,,neo,thematrix
agentsmith-pc,,neo,thematrix
---,,,
---[THEMATRIX]---,,,
merovingian-pc,,neo,thematrix
theoracle-pc,,neo,thematrix
thesource-pc,,neo,thematrix
---,,,
---[ZION]---,,,
cypher-lt,,neo,thematrix
morpheus-pc,,neo,thematrix
tank-lt,,neo,thematrix
trinity-pc,,neo,thematrix
Código v0.3 revisado:
' 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
'
' Updated by Jack Hamilton, to make it work in Remote Desktops v5.2.3790.0
' Version: 0.3 - 2012-08-15
'
' NOTES:
' (1) If you get subscript out of range error, check your CSV for any blank lines
' or lines with too many commas and fix/delete them.
'
' (2) Be sure to close all programs before running, especially those like email
' or instant messaging that can pop up a notification window causing the
' window focus to change and thereby interrupt the automation process.
'———————————————————————
'Declare some variables
Option Explicit
Const ForReading = 1
Const Sleep_Long_Pause = 1500
Const Sleep_Between_Keys = 200
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 = ".\blanktsmmc.msc"
strWorkingMMC = "c:\windows\system32\tsmmc.msc"
strTemplate = ".\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 Sleep_Long_Pause
' 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
Wscript.Sleep Sleep_Between_Keys
' create a new group
objShell.SendKeys "%f"
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "m"
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "%d"
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "rem"
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "%a"
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "%c"
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "{ENTER}"
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "{END}"
Wscript.Sleep Sleep_Between_Keys
Else
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "+{F10}"
Wscript.Sleep Sleep_Between_Keys
' Add Connection
objShell.SendKeys "A"
Wscript.Sleep Sleep_Between_Keys
' IP/Hostname
objShell.SendKeys arrRDPList(0)
objShell.SendKeys "{TAB}"
Wscript.Sleep Sleep_Between_Keys
' skip Browse button
objShell.SendKeys "{TAB}"
Wscript.Sleep Sleep_Between_Keys
' Description
If arrRDPList(1) = "" Then
objShell.SendKeys arrRDPList(0)
Else
objShell.SendKeys arrRDPList(1)
End If
Wscript.Sleep Sleep_Between_Keys
' Skip "Connect to Console"
objShell.SendKeys "{TAB}"
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "{TAB}"
Wscript.Sleep Sleep_Between_Keys
' Username
objShell.SendKeys arrRDPList(2)
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "{TAB}"
Wscript.Sleep Sleep_Between_Keys
' Skip Password
objShell.SendKeys "{TAB}"
Wscript.Sleep Sleep_Between_Keys
' Domain
objShell.SendKeys arrRDPList(3)
' Skip "Save Password"
objShell.SendKeys "{TAB}"
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "{TAB}"
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "{ENTER}"
Wscript.Sleep Sleep_Between_Keys
end if
Loop
' get back to left column
objShell.SendKeys "+{TAB}"
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "^s"
WScript.Quit
FYI, para quem ainda usa o & Brett & A solução de Brian, aqui está minha modificação mais recente para áreas de trabalho remotas (tsmmc) no Windows 7 (64 bits, em).
NOTA: O arquivo blanktsmmc não é mais necessário. O formato tsmmc.csv que reside no mesmo diretório que o script VB ainda é o mesmo, onde desc, user, domain são opcionais (apenas deixe como "server ,"). A primeira linha de cada grupo é um nome de conexão falso usado apenas para identificar o grupo. O --- , observa que um novo grupo RemoteDesktop deve ser feito:
---[GroupA]---,,,
server,desc,user,domain
server,desc,user,domain
---,,,
---[GroupB]---,,,
server,desc,user,domain
server,desc,user,domain
---,,,
---[GroupC]---,,,
server,desc,user,domain
server,desc,user,domain
' 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
'
' Updated by Jack Hamilton, to make it work in Remote Desktops v5.2.3790.0
' Version: 0.3 - 2012-08-15
'
' Updated by Jack Hamilton, to allow more sleep on Remote Desktops launch
' to allow application to get focus before commands executed.
' Version: 0.4 - 2012-12-27
'
' Updated by Jack Hamilton for Windows 7. You cannot
' overwrite c:\windows\system32\tsmmc.msc, so added step at the end
' where user is prompted to Save As. User can then just execute
' using the new msc filename or create shortcut.
' Version: 0.5 - 2013-01-09
'
' NOTES:
' (1) If you get subscript out of range error, check your CSV for any blank lines
' or lines with too many commas and fix/delete them.
'
' (2) Be sure to close all programs before running, especially those like email
' or instant messaging that can pop up a notification window causing the
' window focus to change and thereby interrupt the automation process.
'
'———————————————————————
'Declare some variables
Option Explicit
Const ForReading = 1
Const Sleep_Long_Pause = 1000
Const Sleep_Between_Keys = 250
Dim objShell, objFSO, objFileCopy, objDictionary, objTextFile
Dim strWorkingMMC, strTemplate, strNextLine
Dim arrRDPList
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objDictionary = CreateObject("Scripting.Dictionary")
strWorkingMMC = "c:\windows\system32\tsmmc.msc"
strTemplate = ".\tsmmc.csv"
Set objTextFile = objFSO.OpenTextFile (strTemplate, ForReading)
' start up MMC
objShell.Run strWorkingMMC
' wait for the app to start
' NOTE: We need to have enough time for the
' Remote Desktops application to launch
' else MANY weird, bad things can happen
' if we don't have focus on the application
' else random commands start getting executed.
' Add more sleeps if app is slow to launch
' on this particular PC.
Wscript.Sleep (Sleep_Long_Pause * 5)
' 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
' Open File Menu
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "%f"
' Add/Remove Snap-In
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "m"
' Highlight Remote Desktops Snap-In
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "Remote Desktops"
' Add the highlighted available snap-in on left column
' over to the right-column
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "%a"
' Click OK
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "{ENTER}"
' Move to bottom snap-in
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "{END}"
' End create new group
Else
' Create new server connection
' Show Menu
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "+{F10}"
' Add Connection
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "A"
' IP/Hostname
Wscript.Sleep Sleep_Between_Keys
If arrRDPList(1) = "" Then
objShell.SendKeys arrRDPList(0)
Else
objShell.SendKeys arrRDPList(1)
End If
' Tab
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "{TAB}"
' Username, Domain Info
Wscript.Sleep Sleep_Between_Keys
If arrRDPList(3) = "" Then
' Just Username, No Domain
objShell.SendKeys arrRDPList(2)
Else
' Username@Domain
objShell.SendKeys arrRDPList(2)
objShell.SendKeys "@"
objShell.SendKeys arrRDPList(3)
End If
' Tab
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "{TAB}"
' Save Password
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys " "
' Tab
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "{TAB}"
' Browse button (skip)
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "{TAB}"
' Description
Wscript.Sleep Sleep_Between_Keys
If arrRDPList(1) = "" Then
objShell.SendKeys arrRDPList(0)
Else
objShell.SendKeys arrRDPList(1)
End If
' Skip "Connect to Console (w /admin option)"
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "{TAB}"
' Click OK
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "{ENTER}"
' End create new server connection
end if
Loop
' Return to left-side column
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "+{TAB}"
' Open File Menu
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "%f"
' Open Save As to prompt user to save with new name.
Wscript.Sleep Sleep_Between_Keys
objShell.SendKeys "a"
' Quit Program
Wscript.Sleep Sleep_Between_Keys
WScript.Quit