WinBatch and running programs on a Remote Desktop Connection

Started by Brian, January 06, 2015, 09:04:29 PM

Previous topic - Next topic

Brian

Our business and our clients run most of the applications from a Windows Remote Desktop.

While I can use WinBatch to initiate the Remote Desktop session I am not able to then run a program, using WinBatch, on that Remove Desktop.

For example if I want to start NotePad it starts the notepad on my local PC.


Trying code such as below where the Remote Desktop window has label of "QA130 - ........."


I find that it starts Notepad BUT on my local PC not the remote desktop.

Any suggestions?

Thanks,

Brian
------------------------------------------------------------------------------------------------------------------

If WinExist("~QA130 -") == @TRUE

  If WinActivate("~QA130 - ") == @TRUE
    Run("Notepad.exe","")
    Message("Message Window","Notepad Starting")
  Else
    Message("Message Window","Cannot activate QA130")
  EndIf

Else
  Message("Loading M&L Test", "Cannot start M&L from RDP")
EndIf

-------------------------------------------------------------------------------------------------




Russell_Williams

The easiest way is for you to put your Winbatch exe on the Remote Desktop itself instead of locally on your station.
Since that is where the applications run, then Winbatch code can run there also.
For example on the Remote Desktop make a C:\WINBATCH folder and put MYPROG.EXE in that folder (nothing is on the local station that started the RDP session).
Then inside the RDP window, browse and run C:\WINBATCH\MYPROG.EXE
That will instance it over on the remote server, which will run the Notepad inside there. Remember that MYPROG.EXE will not see a "QA130" window because it is running on the other system.
Nothing will run locally in that case.

DAG_P6

Alternatively, you may be able to run it on the remote desktop without moving it by way of the \\tsclient\c\winbatch directory. This assumes, of course, that you elected to share your C drive with the remote machine, which I almost always do. When you share a drive, the remote desktop client creates a temporary share called \\tsclient\d, where "d" is the letter of the shared drive, as seen from your machine. To do this, you must start from the remote desktop. You may either navigate to the share by way of the file explorer, or work from a command prompt. Since populating the share is quite slow, I almost always use a command prompt, and use the explorer on my local machine to work out the path.
David A. Gray
You are more important than any technology.