hi, as i am in the exotic but same situation using both remote desktop and vnc to connect to my win xp pro server in my living comunity lan, i found a workaround for the session zero problem yesterday.
i m not a professional when it comes to these hacks and batches, so when someone finds a better way he should post it, but as a basic solution, this is what i did: i use a win xp pro system as server, so theres only one remote desktop session active at a time and one user logged in. if i take over session 0 with a remote desktop client, all processes that show other login or locked screens will be on session 1, 2, 3 and so on. so does the "real" console (the one your server monitor would display). active session always stays id 0 so i can always connect to an active remote desktop session with vnc having the screen visible twice. what happens when i disconnect the rd session is that everything stays on its session ids awaiting user actions. what happens when i logoff with the rd session is that session 0 becomes "vacant" but everything else keeps staying on its session id untill you would logon manually and physically on the server (which would solve the problem too but we want it magically remotely not physically... ;D ). thats why one always gets a black screen on vnc connecting to session id 0 when it is "not in use". being logged onto a machine via rd and having displayed the taskmanager that showed the session id column in the process table, one can play around in a dos box with typing RESET SESSION n (n being the id that is not zero) and one can see how the console processes like logon and logon screensaver "slip around" on ids 1,2,3 when you reset their session ids. i plugged a monitor onto the server and watched the logon screen becoming black for like one second and coming back again while its session was reset and changed id. so i suspected that the console session being reset would fall to session id 0 if 0 would be "available" at that moment. so everything we have to do is to reset the console session (2 or 3 or whatever) while not being logged in, after we took over session 0 with rd. that means i cannot take over back the same session. i have to logoff making session 0 "available" then while nobody is logged in, i have to run a script or batch that resets the console session which is still on an id bigger than 0. as i have running a webserver as a service on that machine i was able to trigger these things from inside a cgi script. there must be other (better) solutions for this but this was the easyest thing for me. most of what i needed (as i am not really experienced in hacks like that) i found on http://terminal.servebeer.com/php/reset_winstations.php and ajusted the batch script for my needs. so to logoff everybody from the machine i took excactly what the author wrote: For /f "tokens=2" %i in ('QWinSta ^| Find /i "listen"') Do Echo y | RWinSta %i that took a few seconds at least on my machine just to make sure nobody keeps blocking session id 0. so right now if you would connect using vnc you would see the black screen. and actually now you can do so and leave it open running and wait for the logon box appearing while executing the following on the server: (oops that one comes from me...) For /f "tokens=2" %i in ('QWinSta ^| Find /i "Conn"') Do Echo y | IF NOT [%i]==[0] RWinSta \%i for some reason now the "session id slipping around" to id 0 takes much longer than doing so while having id 0 active. but as soon as the batch completes, you will have the background colour again visible in your vnc window (blue in my case) and after like one or two minutes first the pointer then the logon window appears and all the processes nicely run on session id 0 again. (if someone knows a reason why this could harm a computer for some topics please tell me... of course i did that and you will on your own risc) thats it. probably there are better methods or faster ones or ones that do not require a logoff or maybe the reset session call can be integrated into a clean vnc server feature, or someone can write a script that runs automatically after logoff without the need of a web-server. i have the scripts in my cgi-bin. a version to be used from the outside which is password protected and a very simple version for the internal use. so the resettssessions.pl looks as follows. i hope that this post can be useful to others and i apologize for me smartassing around here not really being a pro on ts, rd, batching and mailing lists. cheers :) /joerg the script: #!/usr/bin/perl # # found and weiterverhackt on http://terminal.servebeer.com/php/reset_winstations.php print "Content-Type: text\/plain\n\n"; if (substr($ENV{'REMOTE_ADDR'},0,10) ne "192.168.0.") { print "[STATUS]\nstatus=error\n\n[ERROR]\nerror=noauth\n" } else { system("For /f \"tokens=2\" \%i in ('QWinSta ^| Find /i \"Conn\"') Do Echo y | IF NOT [\%i]==[0] RWinSta \%i"); print "[STATUS]\nstatus=success\n\n[ACTION]\nresetting ts sessions\n" } _______________________________________________ VNC-List mailing list [email protected] To remove yourself from the list visit: http://www.realvnc.com/mailman/listinfo/vnc-list
