Tuesday, June 25, 2019

windows 7 - RDP logout using bat file


Using Windows 7. When I RDP to a PC I'd like to be able to logout of the session without the screen reverting to a Ctrl+Alt+Del Login screen.


The PC's in question are kiosks running Chrome in full screen 'Kiosk Mode'. So it's important they revert back to the normal browser home page.


I have successfully managed to do logout by creating a .bat file in C:\bat called rdp_logout.bat. The contents of this .bat file are below;


tscon.exe 2 /dest:console
EXIT

I then created a shortcut on my desktop to this .bat file (send to > desktop). I changed the permissions of the .bat file to run as administrator. When I want to logout of the 'Kiosk' I do the following;



  • Open the browser in Kiosk Mode

  • WinKey+R

  • Input "cmd"

  • Enter


This opens the command prompt (on top of) the browser with the following displayed;


C:\Users\Administrator


I then type;


cd Desktop


"rdp_logout.bat - Shortcut.lnk"


This does run, and logs me out. However whenever I RDP to the same PC immediately afterwards, the command prompt window is still showing 'on top' of the browser.


What do I need to change in order to hide the command window after the .bat files has ran?


Answer



Try this.


Timeout 2
taskill /f /cmd.exe

to the end of you .bat


This will Kill the window to kill itself after you log out. The Pause is so it does not kill it before your logout command runs.


No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...