Forum / Remote Desktop Manager - Macro/Script/Tools

RDM Variables into cmd

  • Create an Issue
  • Cancel

Hello. I am trying to build a .bat file for RDM to remotely access workstations using RDP shadow.
Right now, we use this script, it interacts with us and asks for computer name and then for session number:

@echo off
set /P rcomp="Enter name or IP of a Remote PC: "
query session /server:%rcomp%
set /P rid="Enter RDP user ID: "
start mstsc /shadow:%rid% /v:%rcomp% /control /noConsentPrompt


How can i send a variable into this script, e.g. $COMPUTERNAME instead of %rcomp% after i right-click onto workstation and select macros/script/tools?

Thank you!

Clock2 yrs

Hello,

Sorry for the long delay, i tested several possibilities for this one, as i wanted to do it through your .bat file.

I have been able to achieve this with a PowerShell (Local) Macro/Script/Tool.
Create a new entry, in Macro/Script/Tool, PowerShell (Local), select Embedded Script, Click on Edit embedded Script.
In the dialog box, I entered this script :

$SessionID = Read-Host "Enter RDP user ID:"
mstsc /v:$HOST$ /shadow:$SessionID /control /noConsentPrompt



This script will still prompt you for the ID of the connection, through a PowerShell imput (that will look quite the same as what you are already doing)

Then, from a session, the $HOST$ will do the trick.

I hope this helps.

Regards,



Alex Belisle

signaturesignature

Clock2 yrs

Thank you for a reply.
I would like to have the ability to see user sessions in case, multiple users are logged on to computer. query session /server:%rcomp% did it before. However, powershell does not seem to have such command.

Clock2 yrs

Hello,

It turns out that you can run query.exe from a powershell window. simply add the command before the rest like:


query.exe session /server:$HOST$
$SessionID = Read-Host "Session ID"
mstsc /v:$HOST$ /shadow:$SessionID /control /noConsentPrompt


Make sure that the "Run in 64-bits Mode" is checked from the Advanced Tab.


Best regards,



Alex Belisle

signaturesignature

Clock2 yrs

It worked! Thank you very much!

Clock2 yrs

Is there a way to embed RDP window that opens after the script is executed?

Clock30 days

Hello,

Which window are you referring to? Could you post a screenshot?

Best regards,



Jeff Dagenais

signaturesignature

Clock30 days

So, here i choose needed RDP connection and execute a script from Alexandre:

@echo off
set /P rcomp="Enter name or IP of a Remote PC: "
query session /server:%rcomp%
set /P rid="Enter RDP user ID: "
start mstsc /shadow:%rid% /v:%rcomp% /control /noConsentPrompt


1

Then, embedded PowerShell windows opens up, where we enter session id:
2

And finally, external RDP Shadow window pops up externally:
3

Is there a way to open this RDP window as embedded into RDM?

1.PNG
2.PNG
3.PNG
Clock29 days

Hello,

No sure that is possible to run the window in embedded mode.
Let me verify with our engineering department and get back to you.

Best regards,



Jeff Dagenais

signaturesignature

Clock29 days

Hello,

After verification, it would not be possible for us to accomplish this because it's PowerShell that opens MSTSC. It's not linked to RDM.

Best regards,



Jeff Dagenais

signaturesignature

Clock29 days

Okay, understood.

Clock29 days