Jump to content

Recommended Posts

Posted

Hi there,

 

We are currently setting up several thin client PCs to connect to a new terminal server farm. To automatically connect to the farm, I have created a Remote Desktop Connection and dropped it into Startup on each thin client. Therefore when the thin client is booted up, it automatically connects to the Terminal server farm. However, if a user closes their remote sessions or logs off, it then takes them back to the thin client desktop.

 

My question is, if the remote desktop connection is closed/logged off, is there a way to automatically re-establish the remote desktop connection so the thin client then reconnects to the logon page on the ts farm?

 

Any pointers would be a great help!

 

Cheers Rich

Posted (edited)

Simple answer is yes replace the explorer shell with a vb script which is looped.

 

You havent said whnat OS you have on the thin clients, this will work for any version of xp, but wont work for Windows Thin PC.

 

Create an rdp client file and with all the settings you need for accessing your terminal server and save it to

 

c:\windows\system32\school.rdp

 

then create a vb script like this one

 

Option Explicit

'On Error Resume Next

 

Dim objShell

 

Set objShell = CreateObject("WScript.Shell")

 

Do

If (objShell.AppActivate("Remote Desktop") = False) Then

objShell.Run "mstsc.exe C:\WINDOWS\SYSTEM32\school.rdp"

WScript.Sleep 4000

Else

WScript.Sleep 2000

End If

Loop

 

and call it say remote.vbs and also save it to your windows\system32 folder.

 

Now open the registry in

 

HKCU\Software\microsoft\windows nt\current version\winlogon

 

and create a string called "Shell"

and set its value to "remote.vbs"

 

Now when the system boots it should autostart your rdp connecting and reconnect when its closed.

 

good luck

Edited by Bezwick
Posted

This VBS script will work on Thin PC. You need to change the shell to this file. Make sure you put Wscript in front of it wont work

 

for example wscript.exe C:\script.vbs

 

On Error Resume Next
Set fs = CreateObject ("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject ("WScript.Shell")

'Get the username and profile directory
MUser = WshShell.ExpandEnvironmentStrings ("%USERNAME%")
MUserProfile = wshShell.ExpandEnvironmentStrings("%USERPROFILE%")

'Delete icons
fs.DeleteFolder MUserProfile & "\Start Menu\Programs\Accessories",True
fs.DeleteFile  MUserProfile & "\Start Menu\Programs\*.lnk"

'Run the app

wshShell.Run "c:\myapp\app.exe"

' Connect to wmi
set objWMIService = GetObject("winmgmts:root\cimv2")
Do
 found = false
' List the processes
strQuery = "Select * from win32_process where name='app.exe'"
set colProcesses = objWMIService.ExecQuery(strQuery)

for each proc in colProcesses

  ' Get the reference class linking processes to sessions to get the session object path
  strQuery = "References of {win32_process.handle='" & proc.handle & "'} where ResultClass=Win32_SessionProcess"
  set colSessionReferences = objWMIService.ExecQuery(strQuery)

  for each oSessionReference in colSessionReferences
     'Get associators of the session object that are user accounts (linked by win32_loggedonuser)
     strQuery = "Associators of {" & oSessionReference.antecedent & "} where AssocClass=win32_LoggedOnUser"
     set colUsers = objWMIService.ExecQuery(strQuery,,48)
       for each user in colUsers
        if user.name = MUser then found = true
     next
  next
next
Loop While found = true

'Run the Windows 2003 logoff utility
wshShell.Run "c:\windows\system32\logoff.exe"

Posted
Shameless plug! The info you need is over on my blog. Thats exactly how it is set up with us.

 

Hi mate, can you send me a link to the blog entry?

 

Cheers

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...