Announcement

Collapse
No announcement yet.

sending a message from domain to clients

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • sending a message from domain to clients

    gentlemen ,

    when i try to send message to a particular computer or the user i am getting the error message" msg.exe error 5 access is denied " ,please give me the solution.

  • #2
    Re: sending a message from domain to clients

    What is the exact command syntax you are using?
    Tom Jones
    MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
    PhD, MSc, FIAP, MIITT
    IT Trainer / Consultant
    Ossian Ltd
    Scotland

    ** Remember to give credit where credit is due and leave reputation points where appropriate **

    Comment


    • #3
      Re: sending a message from domain to clients

      i am using a vb script from pedros blog also i tried sending the message from net scanner software but i got the same error.

      Comment


      • #4
        Re: sending a message from domain to clients

        Could you possibly help us a bit by posting the script?

        Does the error apply to all computers or just one?
        Have you tried the troubleshooting here?
        http://www.cezeo.com/tips-and-tricks/msg-command/
        Tom Jones
        MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
        PhD, MSc, FIAP, MIITT
        IT Trainer / Consultant
        Ossian Ltd
        Scotland

        ** Remember to give credit where credit is due and leave reputation points where appropriate **

        Comment


        • #5
          Re: sending a message from domain to clients

          hi ,

          this is the script
          ------------

          Option Explicit
          On Error Resume Next
          Const ADS_SCOPE_SUBTREE = 2
          Dim objConnection, objCommand, objRecordSet, objShell, objSA, objArquivoTexto, objProcessEnv
          Dim strDomain, strContent, strCommand, strComputer, strMessage, strComputers, strCall, strLdapDomain
          Dim intCounter, intLines, intDomainParts, intDomainLenght, intPosition, intSent, intNotSent, intComputermatch
          IntNotSent = 0
          IntSent = 0

          Set objShell = CreateObject("WScript.Shell")
          Set objProcessEnv = objShell.Environment("Process")

          'Asks the user to type the message
          strMessage = InputBox("Type the message to be sent to network computer(s)","Messenger Service", strMessage)
          If strMessage = "" Then
          Wscript.Echo "Operation canceled by the user"
          Wscript.Quit
          End If

          'Determines the scope of the message being sent
          strComputer = InputBox("--> Type * for all computers, or " & vbcr & "--> the single computer name, or" & vbcr & "--> a path to a file containing " & vbcr & "a list of computers like c:\list.txt" & vbcr & "PS: Must contain the ':' character in the path","Choose the right scope", strComputer)
          If strComputer = "" Then
          Wscript.Echo "Operation canceled by the user"
          Wscript.Quit
          End If

          If strComputer = "*" then
          ' get the domain name of the user
          strdomain = objProcessEnv("USERDNSDOMAIN")
          If strdomain = "" then
          Wscript.Echo "This computer is not joined in a domain, or maybe the account you have used to" & vbcr & "call the script does not have query privileges to AD. Please try again using" & vbcr & "a computer name or a file with a list containing computer names"
          Wscript.Quit
          else
          intdomainparts = Int(Conta(strdomain,".", false))
          For intCounter = 1 to intdomainparts
          intdomainlenght = len(strdomain)
          If intCounter < intDomainparts Then
          intposition = InStr(strdomain, ".")
          Else
          intposition = intdomainlenght+1
          End if
          strldapdomain = strldapdomain & ",DC=" & left(strdomain, intposition - 1)
          If intCounter < intDomainparts Then
          strdomain = right(strdomain, intdomainlenght-intposition)
          End If
          Next
          End If
          strLdapDomain = right(strldapdomain, len(strldapdomain)-1)
          Set objConnection = CreateObject("ADODB.Connection")
          Set objCommand = CreateObject("ADODB.Command")
          objConnection.Provider = "ADsDSOObject"
          objConnection.Open "Active Directory Provider"
          Set objCOmmand.ActiveConnection = objConnection

          'Get all computer objects in the specified domain
          objCommand.CommandText = "Select Name from 'LDAP://" & strLdapDomain & _
          "' where objectClass='computer'"
          objCommand.Properties("Page Size") = 1500
          objCommand.Properties("Timeout") = 30
          objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
          objCommand.Properties("Cache Results") = False
          Set objRecordSet = objCommand.Execute
          intComputermatch = objRecordSet.RecordCount
          Set objRecordSet = objCommand.Execute ' Necessary to call again on account of the Recordcount

          'Fails when there is an error in the domain name
          If Err.Number <> 0 Then
          Wscript.Echo "The messenger script could not find the domain specified. Check if the ac-" & vbcr & "count used to call the script has enough privileges. No message was sent."
          Wscript.Quit
          Else
          Do While not objRecordSet.EOF
          strComputer = objRecordSet.Fields("name").Value
          Set objShell = CreateObject("WScript.Shell")
          strCommand = objShell.Run ("cmd /c msg * /server:" & strComputer & " " & strMessage,0,True)
          If strCommand <> 0 Then
          intNotSent = IntNotSent + 1
          objShell.Popup strcomputer & " seams to be offline",2
          Else
          intSent = intSent + 1
          objShell.Popup intSent & "/" & intComputermatch & " messages successfully sent to the network, " & vbcr & "but at least " & intNotSent & " computers were offline or " & vbcr & "did not exist or could not be contacted.",1
          End If
          Set objShell = Nothing
          objRecordSet.MoveNext
          Err.Clear
          Loop
          If intNotSent > 0 Then
          wscript.echo intSent & " messages successfully sent to the network, " & vbcr & "but at least " & intNotSent & " computers were offline or did" & vbcr & "not exist or could not be contacted."
          Else
          wscript.echo intSent & " messages sent successfully to the network."
          End If
          End If
          wscript.quit

          Elseif instr(strComputer,":") then

          ' Routine to read a file containing a list of computers
          Set objSA = CreateObject("Scripting.FileSystemObject")
          Const ForReading = 1
          intLines = 0
          Set objArquivoTexto = objSA.OpenTextFile(strComputer, ForReading)
          If Err.Number <> 0 then
          Wscript.echo "The file specified does not exist. Try again with a correct path to the file. Exiting."
          Wscript.Quit
          End If
          strContent = ObjArquivoTexto.ReadAll
          intLines = Conta(strContent, chr(13), false)
          Redim strComputers(intLines+1)

          For intCounter = 1 to intLines
          strCall = GetLine(strContent, intCounter)
          strComputers(intCounter) = strCall
          Set objShell = WScript.CreateObject( "WScript.Shell" )
          strCommand = objShell.Run ("cmd /c msg * /server:" & strComputers(intCounter) & " " & strMessage,0,True)
          If strCommand <> 0 Then
          intNotSent = IntNotSent + 1
          objShell.Popup strComputers(intCounter) & " seams to be offline",2
          Else
          intSent = intSent + 1
          objShell.Popup intSent &"/" & intLines & " messages successfully sent to the network, " & vbcr & "but at least " & intNotSent & " computers were offline or " & vbcr & "did not exist or could not be contacted.",1
          End If
          Set objShell = Nothing
          Next
          If intNotSent > 0 Then
          Wscript.Echo intSent & " messages successfully sent to the network, " & vbcr & "but at least " & intNotSent & " computers were offline or did" & vbcr & "not exist or could not be contacted."
          Else
          Wscript.Echo intSent & " messages sent successfully to the network."
          End If
          Wscript.Quit
          Else
          Set objShell = CreateObject("WScript.Shell")
          strCommand = objShell.Run("cmd /c msg * /server:" & strComputer & " " & strMessage,0,True)
          Set objShell = Nothing
          if strCommand <> 0 Then
          Wscript.Echo "The specified computer does not exist or can be" & vbcr & "offline, or you may not have enough privileges" & vbcr & "to send a message to it. Message not sent."
          else
          Wscript.Echo "Message sent successfully!"
          End If
          End If

          wscript.quit

          '----------------------------------------------------------------------------------------------------------------
          ' Functions
          '----------------------------------------------------------------------------------------------------------------

          Function GetLine(strbuffer, Line)

          Dim intEnd, strData, StrLine, IntLine

          StrLine = StrBuffer
          intEnd = InStr(strLine, Chr(13)) ' Get the initial position of ASCII 13 code (ENTER)
          IntLine = 0
          Do
          IntLine = IntLine + 1
          If intEnd > 0 Then
          If IntLine = Line Then
          strLine = Left(strLine, intEnd-1)
          intEnd = InStr(strLine, Chr(13))
          Else
          StrLine = Mid(StrLine,IntEnd+2)
          intEnd = InStr(strLine, Chr(13))
          End If
          Else
          strLine = strLine
          End If
          Loop While IntLine < Line

          GetLine = strLine

          End Function

          '--------------------------------------------------------------------------------------------------------------------

          Function Conta(strText, strFind, fCaseSensitive)
          Dim intCount, intPos, intMode

          If Len(strFind) > 0 Then
          ' Configures the comparison mode.
          If fCaseSensitive Then
          intMode = vbBinaryCompare
          Else
          intMode = vbTextCompare
          End If
          intPos = 1
          Do
          intPos = InStr(intPos, strText, strFind, intMode)
          If intPos > 0 Then
          intCount = intCount + 1
          intPos = intPos + Len(strFind)
          End If
          Loop While intPos > 0
          Else
          intCount = 0
          End If
          Conta = intCount+1
          End Function




          and i made group policy in the domain as follows :

          Group Policy Management Tool in: Administrative Tools / Group Policy Management. Now right click the "Default Domain Policy" in the domain Root, and click "Edit". Navigate through "Computer Configuration", "Preferences", "Windows Settings" and then open "Registry". Now create a registry item, right-clicking the "Registry" node and choosing the "New -> Registry Item". In the "action" section choose "replace" and leave the selection in the hive "HKEY_LOCAL_MACHINE" and in the "Key Path", click in the "..." button. Choose this key path:

          SYSTEM\CurrentControlSet\Control

          In the "Value Name", type "AllowRemoteRPC" (without the slashes shown here). In the "value type" choose "REG_DWORD", and in the "value data" field type "1" (without the slashes). Choose also the base as "hexadecimal" and the click OK.

          Comment


          • #6
            Re: sending a message from domain to clients

            Hi ,


            This is the link i have tried ...

            http://gallery.technet.microsoft.com...t-for-810f8331

            Comment


            • #7
              Re: sending a message from domain to clients

              Maybe it should be this your following

              http://technet.microsoft.com/en-us/l...(v=WS.10).aspx

              Comment


              • #8
                Re: sending a message from domain to clients

                i did that too but same error...

                Comment


                • #9
                  Re: sending a message from domain to clients

                  please tell me how to send messages in a local network ? server 2008 and all clients are using windows 7 ...

                  Comment


                  • #10
                    Re: sending a message from domain to clients

                    All of the following will work....
                    1) Walk around local network telling users what the message is
                    2) Print message out multiple times and leave on keyboards
                    3) Carrier Pigeon
                    4) Email

                    Alternatively stick with trying to fix the problem you originally reported which was a specific error with MSG.EXE. I asked several questions in Post #4 which you have not answered. Also, does the script work for the server you are logged on to?
                    Tom Jones
                    MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
                    PhD, MSc, FIAP, MIITT
                    IT Trainer / Consultant
                    Ossian Ltd
                    Scotland

                    ** Remember to give credit where credit is due and leave reputation points where appropriate **

                    Comment

                    Working...
                    X