Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Automating Remote Desktops MMC Snapin

Reply
 
Old 09-22-2008   #1 (permalink)
Colin Griffiths


 
 

Automating Remote Desktops MMC Snapin

Hi,

I'm trying to write a scrip to automate adding hosts to the Remote Desktops
MMC snap in.

I can create a new MMC session and open the Add New Connection dialogue, but
have got stuck there.

Code:
Option Explicit
Const ForReading = 1

Wscript.Echo "This script uses the MMC 2.0 Application object."

' Create the MMC Application object.
Dim WshShell, objMMC, objNode, View, listitem, host, StdIn, fso
Set objMMC = Wscript.CreateObject("MMC20.Application")

' Show the MMC application.
objMMC.Show

' Add the "Remote Dssktops" snap-in to the console.
objMMC.Document.SnapIns.Add("Remote Desktops")

Set StdIn = WScript.StdIn
Set fso = CreateObject("Scripting.FileSystemObject")

' Read the contents of the file.

Set StdIn = fso.OpenTextFile("c:\\hosts.txt", ForReading)

Do While Not StdIn.AtEndOfStream

host = StdIn.ReadLine
objMMC.Document.ScopeNamespace.Expand(objMMC.Document.RootNode)
Set objNode =
objMMC.Document.ScopeNamespace.GetChild(objMMC.Document.RootNode)
WScript.Echo "Selected object is " + objNode.Name

Set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Sleep 100
WshShell.SendKeys "{DOWN}"

WScript.Echo objMMC.Document.ActiveView.ActiveScopeNode.Name
WScript.Echo
objMMC.Document.ActiveView.ScopeNodeContextMenu.Item(2).DisplayName

objMMC.Document.ActiveView.ScopeNodeContextMenu.Item(2).Execute
WScript.Sleep 100
'How to enter the host details here?

Loop


' Leave the MMC application in user control when this script ends.
objMMC.UserControl = 1

My System SpecsSystem Spec
Old 09-22-2008   #2 (permalink)
Colin Griffiths


 
 

RE: Automating Remote Desktops MMC Snapin

I've managed to script the "Add new Connection" dialogue with SendKeys,
however I've also just discovered control does not pass back to the script
until dialogue closed after the .Execute method is called.
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Remote Desktops - UAC control - Why? Vista security
remote desktopS? Vista General
Remote Desktops (tsmmc) Vista networking & sharing
automating logon to remote server PowerShell
Vista Remote Desktops Vista networking & sharing


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46