Thought I would post here as I couldn't post in the scripts / tips section.
I work in IT in a hospital and am constantly trying to contact staff / users of a computer to perform work for them. Problem is hospital has poor mobile phone coverage and trying to get them on a desk phone can be a real pain.
I have tried sending emails etc, but they get some many emails it makes it really hard to make contact.
I remember the old Net Send days, although now blocked / disabled since XP SP2. I do remember there is the msg command, although it was really only for terminal services to message individual users, it can be used to message users on an individual machine providing they have the registry key enabled.
Now you still need to have admin access to the remote machine to enable the registry key, in my situation I need to run it with my admin account.
Here is what it looks like: YouTube Video Link
Now I am sure there can be some additional checks added to make it 100% reliable, it was written quickly for my purpose, however now that I think about it, it could be useful for others, so feel free to have a look.
Code: Select all
// COMPILE_OPTS|C:\Temp\MJ\MSGUtility.exe|M:\Icons\e_mail.ico|CONSOLE=0|INCLUDES=1| /HIDE /NOSYSTRAY /LOGFILE=\dev\nul
Let>APP_TITLE=MSG Utility v1.1
Let>MSG_HEIGHT=320
Let>MSG_WIDTH=500
Let>MSG_STAYONTOP=1
Let>MSG_CENTERED=1
Let>RP_ADMIN=1
Dialog>MSGUtility
object MSGUtility: TForm
Left = 247
Top = 96
HelpContext = 5000
BorderIcons = [biSystemMenu, biMinimize]
BorderStyle = bsSingle
Caption = 'MSG Utility'
ClientHeight = 298
ClientWidth = 466
Color = clBtnFace
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Courier New'
Font.Style = []
OldCreateOrder = True
Position = poScreenCenter
ShowHint = True
OnTaskBar = True
PixelsPerInch = 96
TextHeight = 16
object msLabel1: TLabel
Left = 8
Top = 48
Width = 56
Height = 16
Caption = 'Message'
Transparent = True
end
object msLabel2: TLabel
Left = 8
Top = 216
Width = 32
Height = 16
Caption = 'From'
Transparent = True
end
object msLabel3: TLabel
Left = 16
Top = 267
Width = 248
Height = 16
Caption = 'Created By Michael Allen '#169' 2012'
Transparent = True
end
object msLabel5: TLabel
Left = 8
Top = 8
Width = 144
Height = 16
Caption = 'Enter Machine Name'
Transparent = True
end
object MachineNumber: TEdit
Left = 16
Top = 24
Width = 433
Height = 24
TabOrder = 0
end
object Message: tMSMemo
Left = 16
Top = 64
Width = 433
Height = 145
ScrollBars = ssVertical
TabOrder = 1
end
object From: TEdit
Left = 16
Top = 232
Width = 433
Height = 24
TabOrder = 2
end
object msButton1: tMSButton
Left = 272
Top = 264
Width = 91
Height = 25
Caption = 'SEND'
Default = True
DoubleBuffered = True
ParentDoubleBuffered = False
ParentShowHint = False
ShowHint = False
TabOrder = 3
DoBrowse = False
BrowseStyle = fbOpen
end
object msButton2: tMSButton
Left = 368
Top = 264
Width = 83
Height = 25
Caption = 'CLOSE'
DoubleBuffered = True
ModalResult = 2
ParentDoubleBuffered = False
ParentShowHint = False
ShowHint = False
TabOrder = 4
DoBrowse = False
BrowseStyle = fbOpen
end
end
EndDialog>MSGUtility
SetDialogProperty>MSGUtility,,Caption,%APP_TITLE%
Label>Start
AddDialogHandler>MSGUtility,msButton2,OnClick,GoEXIT
AddDialogHandler>MSGUtility,msButton1,OnClick,SendMSG
Show>MSGUtility,result
If>result=2,Exit
SRT>SendMSG
GetDialogProperty>MSGUtility,MachineNumber,Text,DNUM
GetDialogProperty>MSGUtility,Message,Text,DMSG
GetDialogProperty>MSGUtility,From,Text,DFROM
If>{(%DNUM%="") OR (%DMSG%="") OR (%DFROM%="")}
MessageModal>Please ensure you have completed all the required fields!%CRLF%· Machine%CRLF%· Message%CRLF%· From
Else
SetDialogProperty>MSGUtility,msButton1,Caption,PLEASE
SetDialogProperty>MSGUtility,msButton2,Caption,WAIT
SetDialogProperty>MSGUtility,msButton1,Enabled,False
SetDialogProperty>MSGUtility,msButton2,Enabled,False
DeleteFile>%TEMP_DIR%MSGUtility.txt
WriteLn>%TEMP_DIR%MSGUtility.txt,,%DMSG%%CRLF%--%CRLF%From: %DFROM% - %USER_NAME%
Let>RP_WAIT=1
Let>RP_WINDOWMODE=0
Let>RP_DISPLAYERROR=0
Run>cmd /c REG ADD "\\%DNUM%\HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v "AllowRemoteRPC" /t REG_DWORD /D 1 /F > "%TEMP_DIR%AllowRemoteRPC.txt"
Run>cmd /c MSG /V /TIME:86400 /SERVER:%DNUM% * <"%TEMP_DIR%MSGUtility.txt" >"%TEMP_DIR%MSGResponse.txt"
Run>cmd /c REG ADD "\\%DNUM%\HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v "AllowRemoteRPC" /t REG_DWORD /D 0 /F > "%TEMP_DIR%AllowRemoteRPC.txt"
ReadFile>%TEMP_DIR%MSGResponse.txt,MSGSentResults
DeleteFile>%TEMP_DIR%MSGUtility.txt
DeleteFile>%TEMP_DIR%AllowRemoteRPC.txt
DeleteFile>%TEMP_DIR%MSGResponse.txt
StringReplace>%MSGSentResults%,86400,24hr's,MSGSentResults
//MDL>MESSAGE SENT%CRLF%==========================%CRLF%TO: %DNUM%%CRLF%%CRLF%MESSAGE%CRLF%%DMSG%%CRLF%--%CRLF%From: %DFROM% - %USER_NAME%
MDL>%MSGSentResults%%CRLF%==========================%CRLF%TO: %DNUM%%CRLF%%CRLF%MESSAGE%CRLF%%DMSG%%CRLF%--%CRLF%From: %DFROM% - %USER_NAME%
SetDialogProperty>MSGUtility,msButton1,Caption,SEND
SetDialogProperty>MSGUtility,msButton2,Caption,CLOSE
SetDialogProperty>MSGUtility,msButton1,Enabled,True
SetDialogProperty>MSGUtility,msButton2,Enabled,True
EndIf
END>SendMSG
SRT>GoEXIT
CloseDialog>MSGUtility
END>GoEXIT
Label>Exit