Skip to content

Instantly share code, notes, and snippets.

@ArthurYidi
Created July 13, 2019 03:33
Show Gist options
  • Save ArthurYidi/9756aa08fcd960c2683cf88af4670a4e to your computer and use it in GitHub Desktop.
Save ArthurYidi/9756aa08fcd960c2683cf88af4670a4e to your computer and use it in GitHub Desktop.
remote
@echo off
echo.
echo Remote Desktop will be temporarily disconnected . . . please reconnect after a few seconds.
echo.
pause
@echo on
REM The active session has an arrow as the first character
setlocal EnableDelayedExpansion
FOR /F %%A in ('qwinsta') do (
set tempSessionName=%%A
if "!tempSessionName:~0,1!"==">" (
@echo on
tscon.exe !tempSessionName:~1! /v /dest:console
@echo off
)
)
@echo off
echo.
echo Starting MyProgram.exe . . .
@echo on
start MyProgram.exe
@echo off
echo.
pause
@riso2k4
Copy link

riso2k4 commented Dec 10, 2019

wonderful, thank you!

Any idea how to run this similarly without requiring admin privileges?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment