# Batch "msg" works across a domain?



## Callum_Dawson (Mar 9, 2009)

I've made a notice script for my domain, so if needs be, I can send a message to a certain user(s). But when testing, it only works for local users, it won't work across the domain. Is there any option for "msg" or method to make it work on other computers (even if I must input the computer name). The very simple script is below;


```
@echo off
echo -------------------------------
echo ------Domain Notice Tool-------
echo -------------------------------
set /p user=Username: 
set /p message=Message: 
msg %user% /v /w %message%
pause
```


----------



## Squashman (Apr 4, 2003)

Have yet to play around with msg.exe but it looks like you need to use the server name they are logged on to.


----------



## Callum_Dawson (Mar 9, 2009)

I added "set /p c=Computer: " and "/SERVER:%c%" to the script, but it just says "Error 5 getting session names." Now I've just tried it from the client to the server and it works perfectly. So why can't the server send messeges to the client(s)?


----------



## helpful (Sep 18, 2009)

net send command, this relies on the messager service to be enabled. The messager service was disabled by default (in Windows XP SP2/SP3) due to security concerns.

http://www.microsoft.com/resources/.../xp/all/proddocs/en-us/net_send.mspx?mfr=true


----------



## helpful (Sep 18, 2009)

better option would be to remotely execute a batch/vbs file to display the desired message.

VBS:

http://msdn.microsoft.com/en-us/library/5zdwefhx.aspx

Batch:

http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx


----------



## Callum_Dawson (Mar 9, 2009)

@helpful: Yea, that's for XP, I use Windows 7 and Windows Server 2008.


----------



## Callum_Dawson (Mar 9, 2009)

I looked into PsExec, it's exactly what I need, just it doesn't function correctly... I remotely executed a batch script where it asks for the message, it executed, exept the variable only saved the first character I entered.


----------



## TheOutcaste (Aug 8, 2007)

On the clients you have to make a registry change to allow the incoming connection:

Click *Start | Run* (or press *WinKey+R*), type *regedit*, press *Enter*
Navigate to here:

```
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server
```
Change the *AllowRemoteRPC* item from 0 to 1 (If not present, add it)
You'll have to reboot for it to take effect.

You can use this *.reg* file in a logon script:

```
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server]
"AllowRemoteRPC"=dword:00000001
```
It may not take effect until the next boot though


----------

