Auto login to RDP then log out of PC - wsh

I need to create a script to launch a RDP file when the user logs into windows, ideally as shell so they dont have local access to their desktop. When the log out the RDP server it then logs them out of the windows machine.
I have a test Win 7 VM and this works perfectly:
Set shell = CreateObject("WScript.Shell")
shell.Run "mstsc.exe /multimon \\ashdom01\NETLOGON\RDS\Desktop.rdp", 1, TRUE
shell.Run "logoff"
When i try this on the win 7 Physical machine when i login it logs me out of windows straight away back to press CTRL ALT Del to login. I dont know whats wrong.
If this cannot work is there a way to create a batch file to launch the RDP file then loop through checking task manager for mstsc.exe then when it sees it end it logs the user out of windows.
Any help will be appreciated.
Regards
Allister

Related

Is there a way to connect through remote desktop to a running Windows Server container?

I want to run an old .NET application in a docker windows server container (https://hub.docker.com/r/microsoft/windowsservercore/).
Everything would be easy if this application didn't require an UI. Its UI does a lot of stuff and this stuff cannot be done through command line or other API.
Basically, the perfect thing would be to reach this running container through RDP.
From my understanding, it is nothing more than a service (TermService) running on a certain TCP port (3389 being the default one).
But it seems that TermService is not running in microsoft/windowsservercore containers.
I found an article showing how to activate it : https://withinrafael.com/2018/03/09/using-remote-desktop-services-in-containers/
Basically, I kept the same Dockerfile, just changing some credentials.
#escape=`
FROM microsoft/windowsservercore:1709_KB4074588
RUN net user /add jerome
RUN net user jerome aDifficultPassword
RUN net localgroup "Remote Desktop Users" jerome /add
RUN net localgroup "Administrators" jerome /add
RUN cmd /k reg add "HKLM\System\CurrentControlSet\Control\Terminal Server" /v TemporaryALiC /t REG_DWORD /d 1
I launch the container with this command :
docker run -it -p3389:3389 myimage powershell
When I connect to the container and type some powershell commands to list running services, I can see that TermService is well running. This is the command I use to list services.
Get-Service
When I list opened TCP ports, I can see that 3389 is listened. This is the command I use to show opened ports.
netstat -an
When I try to connect to the container through my remote desktop client, things seems OK at start.
It asks me for host.
Then for a username and password.
If I type wrong credentials, it says me "Wrong credentials", so there is well a communication with the server.
If I type good credentials, nothing happens. No error message at all, but no display screen too...
I don't really know if logs are generated somewhere or not.
I would be OK if instead of RDS, something like TigerVNC was working. I have never tried this tool before but it seems that it could do the job.
How would you do to control a GUI application running in a windows container?
You can find logs for RDP client in event viewer : "Application and Services Logs"\Microsoft\Windows\TerminalServices-ClientActiveXCore. Here's what is says for me :
The client has established a multi-transport connection to the server.
RDPClient_SSL: An error was encountered when transitioning from TsSslStateDisconnected to TsSslStateDisconnected in response to TsSslEventInvalidState (error code 0x8000FFFF).
RDP ClientActiveX has been disconnected (Reason= 2)
reason 2 is session closed by client.
My paranoia tells me that microsoft went back and patched the image to prevent people from using RDP with docker, but who knows, maybe we're just missing something obvious.

Running Bot emulator through docker containers

I have a working bot that interacts normally with the bot emulator.When I added docker support the emulator stopped interacting with the bot.
I read that I should un check the "bypass ngrok for local addresses" in the emulator settings and configure ngrok.
I have trouble understanding what I should do, I downloaded ngrok.exe and it opened a command line under the name "ngrok.exe".
The path for the running project is :"http://localhost:32768/api/messages".
How should I configure ngrok so the emulator will start interacting with the bot ?
Any other approaches would be good to..
I was able to get my docker container to work with my emulator finally, so I'll show you what I had to change to get it to work!
Using: Emulator 4.2.1, ngrok, and a sample echo bot:
Place the ngrok.exe file where you can find it. Mine's in a folder on my desktop. Then open the emulator. In the bottom left, there is a cog wheel for the emulator settings:
That page will open ... emulator settings. In this page, use the browse button to navigate to and select your ngrok.exe file:
I found that it did not matter for me whether or not I checked the 'Bypass' box.
Note (here's what saved me): localhost is mapped to my ipv4
I ran ipconfig /all in my command prompt to get my IPv4, and then went back to the emulator. In the configuration for my bot, where I was supposed to put in my end point (typically https://localhost:3978/api/messages), I replaced the word 'localhost' with my IPv4:
After I did that, I was able to talk to my bot:

Automation engine is unable to playback the test because it is not able to interact with the desktop

I am trying to run Coded UI tests and I get this message. This happens only if I disconnect from the remote session or I have it minimized.
I enabled autologon, the agent is running in interactive mode, disabled screen saver and lock screen but still not working.
What should I try next?
You need to not connect visa remote desktop. Connect once and reboot the machine and do not connect.
Every time you RDP to the test box you need to reset it by rebooting.
Reason: The reason for this is that starting a remote desktop session suspends the local desktop session that the agent needs in order to run tests

How to access a local rails website using virtualbox

I'm working on a local Rails website, and I'd like to access to it from my visrtualbox machine running winXP
From my Ubuntu machine, I use my browser to open http://www.myapp.local:3000
How can I access it from Virtualbox?
Thanks a bunch!
On your xp machine, open up your hosts file at C:\Windows\System32\drivers\etc\hosts in a local text editor like notepad or whatever is on there.
Then add a line like this:
10.70.30.31 www.myapp.local
Where 10.70.30.31 is the IP address of your Ubuntu machine.
Save the hosts file. Then restart whatever browser you're using on the XP box. Make sure you close all of the browser windows you have open as well because your browser will cache your hosts file until you properly restart it.
Once you've opened a new browser window you should be able to access your rails site from the same address you use on your Ubuntu machine.
http://www.myapp.local:3000

Windows Service Printing Behaviour

Alright, I was tasked to develop a Windows Service that listens to a directory for files that are dropped in it, read them, delete them and print out a report.
I installed the service on my work laptop (Win 7 x86) and a test machine (XP x86) under a User account at first. It would do everything as it should except the print the report. No errors, nothing. Then I made it run under Local System and it produced a "No printers found" exception.
Converting the app to a Console Application and running on these machines gave the desired result. OK, so now I was assuming that there are security "stuff" involved.
Then I installed the service on a Server 2008 x64 machine (under Local System) and it just worked. Can anybody explain to me why this is happening? Why does the service allow printing from Server OS but not from a Desktop OS or am I missing something very obvious?
I'm guessing that the printers are installed locally on the server but installed as network printers on the desktop. Local System only have access to local printers.

Resources