RADC or RemoteApp and Desktop Connections are very powerful in combination with Windows 7 or newer. You actually can have Terminalserver or RDS / Remote Desktop Server applications in the users start menu and connect to them in seamless window applications.
Windows 7 made it challenging to even implement those applications in a large scale, for this sole purpose you had to use a PowerShell script that actually imported a WCX file. Windows 8 and especially Windows 10 can do this via GPO nowadays.
The GPO settings allow one RDS farm to be added and they of course will remove the RDS farm if the GPO is changed/removed.
But what about those Windows 7 clients that are still out there and those cases where you actually have other RDS / RADC connections that you want to delete, e.g. manually created ones. I just came across this scenario and wanted to share the script I just wrote. I created two files in order to executed it simply via GPO as a Cscsript in order to avoid any dialog boxes coming up.
1 | CSCRIPT "%~dp0\RADC_Delete.vbs" |
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | 'Define the RDSDNSName - Look up in Registry Key: 'HKCU\Software\Microsoft\Workspaces\Feeds\{unique number - different on each profile/system} 'Key: WorkspaceId 'Put the WorkspaceId in to the RDSDNSName variable Const RDSDNSName = "rds.yourdomain.com" Dim oReg,fso Dim strResult,strWorkspaceFolder,strStartMenuRoot Dim strComputer Dim hDefKey Const HKEY_CURRENT_USER = &H80000001 hDefKey = HKEY_CURRENT_USER strComputer = "." strKeyPath = "Software\Microsoft\Workspaces\Feeds" Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv") oReg.EnumKey hDefKey, strKeyPath, arrSubKeys For Each strSubkey In arrSubKeys strSubKeyPath = strKeyPath & "\" & strSubkey oReg.EnumValues hDefKey, strSubKeyPath, arrValueNames, arrTypes On Error Resume Next oReg.GetStringValue hDefKey, strSubKeyPath, "WorkspaceId", strValue strResult=cstr(strValue) oReg.GetStringValue hDefKey, strSubKeyPath, "WorkspaceFolder", strValue strWorkspaceFolder=cstr(strValue) oReg.GetStringValue hDefKey, strSubKeyPath, "StartMenuRoot", strValue strStartMenuRoot=cstr(strValue) On Error Goto 0 If Len(strResult)>0 Then If LCase(strResult) = LCase(RDSDNSName) Then Set fso = CreateObject("Scripting.FileSystemObject") On Error Resume Next If fso.FolderExists(strWorkspaceFolder) Then fso.DeleteFolder strWorkspaceFolder, True End If If fso.FolderExists(strStartMenuRoot) Then fso.DeleteFolder strStartMenuRoot, True End If DeleteSubkeys HKEY_CURRENT_USER, strSubKeyPath On Error Goto 0 Set fso = Nothing End If End If Next Set oReg = Nothing Sub DeleteSubkeys(HKEY_CURRENT_USER, strKeyPath) oReg.EnumKey HKEY_CURRENT_USER, strKeyPath, arrSubkeys If IsArray(arrSubkeys) Then For Each strSubkey In arrSubkeys DeleteSubkeys HKEY_CURRENT_USER, strKeyPath & "\" & strSubkey Next End If oReg.DeleteKey HKEY_CURRENT_USER, strKeyPath End Sub |
The .CMD executes the .VBS an expects it in the same directory of course. In the .VBS you will need to change the 5th line – as inidicated. Everything else you can leave as is. Of course this script will only delete the specified connection. You could define the line 5 parameter and change line 33 from
1 | If LCase(strResult) = LCase(RDSDNSName) Then |
to the following line
1 | If LCase(strResult) = LCase(RDSDNSName) Then |
This would result in to deleted everything but the defined connection and therefor do a cleanup. In theory you could then put a empty string in line 5 and just clean up everything.
As always, I hope some of you find this helpful.