5

I have Windows Server 2008R2 with Remote Desktop Services. I need certain program started on every connection, within normal remote desktop environment.

I tried this group policy: "Local Group Policy" ==> "Computer Configuration" ==> "Administrative Templates" ==> "Windows Components" ==> "Remote Desktop Services" ==> "Remote Desktop Session Host" ==> "Remote Session Environment" ==> "Start a program on connection"

Problem is, it replaces desktop environment with a single program: there is no task bar, no start menu, and when user quits the program, session ends.

I need a program to be started within normal desktop environment, just like "Start Menu ==> Programs ==> StartUp", but for every successive connection, not just initial one.

I don't mind hacky solution, I just need to get it done.

Sergei
  • 161

2 Answers2

4

Use Task Scheduler.

Set it up on each computer or remote desktop.

First start Task Scheduler.

Name it and put a description if you would like.

enter image description here

Next click Triggers. Here you will select what you want to start the program in this case you want the program to start at logon.

Or as in Your case you figures out "Connection from remote computer" will work in place of the logon.

Here you can select at any logon or setup certain accounts that logon.

enter image description here

Next you select your program. Place your program path. As well as the start Dir.

enter image description here

Now when ever you connect via Remote Desktop you will have the desktop environment as well as the program you want to start when you login.

0

This works for MS RDP connections (mstsc.exe):

https://learn.microsoft.com/de-de/windows/win32/setupapi/run-and-runonce-registry-keys

HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

%appdata%\microsoft\windows\start menu\programs\startup

Or try this (haven't tested on RDP, works on standard login though):

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon

"Shell" value -> "wscript mystartup.vbs"

and then inside the VBScript:

https://dynwrapx.script-coding.com/dwx/pages/dynwrapx.php?lang=en

set StdRegProv = GetObject("winmgmts:\\.\root\cimv2:StdRegProv")
set activex = wscript.createobject("DynamicWrapperX")
set activex2 = CreateObject("shell.application")

activex.register "user32", "FindWindowW", "i=ww", "r=h"

activex.register "kernelbase", "RegCreateKeyExW", "i=hwuwuuppp"

phkResult = activex.StrPtr("phkResult")

StdRegProv.EnumKey &H80000001, "Software\Microsoft\Windows\CurrentVersion\Explorer\SessionInfo", sKeys

activex.RegCreateKeyExW &H80000001, "Software\Microsoft\Windows\CurrentVersion\Explorer\SessionInfo" & sKeys(0) & "\RunStuffHasBeenRun", 0, 0, 1, 0, 0, phkResult, 0

activex.RegCreateKeyExW &H80000001, "Software\Microsoft\Windows\CurrentVersion\Explorer\SessionInfo" & sKeys(0) & "\StartupHasBeenRun", 0, 0, 1, 0, 0, phkResult, 0

activex.RegCreateKeyExW &H80000001, "Software\Microsoft\Windows\CurrentVersion\Explorer\SessionInfo" & sKeys(0) & "\LogonSoundHasBeenPlayed", 0, 0, 1, 0, 0, phkResult, 0

activex2.shellexecute "explorer"

' ############################################################################# check if already run set cimv2 = getobject("winmgmts:")

set wmi = cimv2.execquery("select Name from Win32_Process where Name = 'XXX'") ' XXX -> some app you are launching below, if already started, quit

if wmi.count then wscript.quit end if

' ############################################################################# wait for explorer do wscript.sleep(500)

hwnd = activex.FindWindowW("Shell_TrayWnd", 0)

loop until hwnd > 0

' ############################################################################# launch your apps ' activex2.shellexecute whatever.exe

WRFan
  • 47