Sep092008

VBS Script To Send Remote Desktop Connection History To Excel

Published by naveed at 2:02 AM under

This VBS script will allow you to enter a local or remote machine name into an input dialog box and will read the registry key containing the list of the Most Recently Used (MRU) history for your Remote desktop connections. The results will then be sent to an Excel spreadsheet listed alphabetically.

VBS Script:

strComputer = InputBox ("Enter Machine Name")

Const Hkey_Current_User = &H80000001

Const REG_SZ = 1

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True

objExcel.Workbooks.Add

intRow = 2

objExcel.Cells(1, 1).Value = "Connection"

Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")

strKeyPath = "Software\Microsoft\Terminal Server Client\Default"

objRegistry.EnumValues HKEY_Current_User, strKeyPath, arrDataValue, arrValueTypes

For i = 0 to UBound(arrDataValue)

strData = arrDataValue(i)

strMRU = arrDataValue(i)

objRegistry.GetStringValue HKEY_Current_User,strKeyPath, strMRU,strValue

objExcel.Cells(intRow, 1).Value = strValue

intRow = intRow + 1

Next

objExcel.Range("A1").Select

objExcel.Selection.Interior.ColorIndex = 19

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Cells.EntireColumn.AutoFit

Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)

Set objRange = objExcel.Range("A1")

objRange.Sort objRange,1,,,,,,1

MsgBox "Done"



[Digg] [Google] [Facebook]

Tags:

E-mail| Permalink | Trackback | Post RSSRSS comment feed 0 Responses

Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading