How to Send a Prompt to a Remote Desktop that Triggers an Action

0

We have a virtual machine (via Azure) in our office environment. In this VM we run Python scripts to analyse the data we pull.

There are five of us on the team, and every time one of us goes on whilst someone else is in the VM, the person already on gets kicked off.

Is there a way to push a prompt of the VM that asks if anyone is on, with Yes or No buttons? Currently I have this code in a batch file:

@echo off

echo code=Msgbox("Is someone one the VM?", vbYesNo, "VM?") > "%temp%\popupBox.vbs"
echo WScript.Quit code >> "%temp%\popupBox.vbs"
cscript /nologo "%temp%\popupBox.vbs"

if %errorlevel%==7 call :cancel_tag
if %errorlevel%==6 call :ok_tag
exit /b 1

:ok_tag
echo Yes I am!
exit /b

:cancel_tag
echo No!
exit /b

This obviously only works on the computer you are using, I was hoping to find a way to have this pushed onto the VM and if someone presses 'Yes' then nothing happens. If someone presses 'No' or there is a time delay where no one answers (as there is no one on the VM) then it will run another batch file that we have that automatically logs into the VM for you. Is this doable?

So far we have tried looking for solutions in cmd or PowerShell as the VM has these pre-installed, but our team has experience using different forms of code so would be willing to tried other forms that would work.

Msg and Net Send is not working for us. We are using Windows 10.

Thanks,

Mammoth

user1042739

Posted 2019-05-29T10:42:06.233

Reputation: 1

Answers

0

The code you are showing is .bat/.cmd file, not a PowerShell script. PowerShell, can pop dialog / message box without ever resorting to batch files.

Net Send being an OS tool, can do this, to the machine, or user, but you have to tell it what to use.

You are not showing you are using any of the Net send parameters in your net send call. You are also not saying if the target is in the same forest / domain as the user.

You cannot send a message to a user / computer using the below that is not in the same domain. Computers and names must be resolvable.

net send
The syntax of this command is:

NET
    [ ACCOUNTS | COMPUTER | CONFIG | CONTINUE | FILE | GROUP | HELP |
      HELPMSG | LOCALGROUP | PAUSE | SESSION | SHARE | START |
      STATISTICS | STOP | TIME | USE | USER | VIEW ]

You could use msg.exe instead

msg
Send a message to a user.

MSG {username | sessionname | sessionid | @filename | *}
    [/SERVER:servername] [/TIME:seconds] [/V] [/W] [message]

  username            Identifies the specified username.
  sessionname         The name of the session.
  sessionid           The ID of the session.
  @filename           Identifies a file containing a list of usernames,
                      sessionnames, and sessionids to send the message to.
  *                   Send message to all sessions on specified server.
  /SERVER:servername  server to contact (default is current).
  /TIME:seconds       Time delay to wait for receiver to acknowledge msg.
  /V                  Display information about actions being performed.
  /W                  Wait for response from user, useful with /V.
  message             Message to send.  If none specified, prompts for it
                      or reads from stdin.

msg SomeDomainUserName /server:SomeDomainHostname message logoff

If you want use PowerShell, you can, there are lots of articles on that topic.

PowerShell Script To Send Message To Network Computer(s)

How to display a pop up message in a remote computer using powershell

jdhitsolutions/Send-PopupMessage.ps1

postanote

Posted 2019-05-29T10:42:06.233

Reputation: 1 783