Jump to content

GUI For MSG.EXE (Help Needed)


Go to solution Solved by MiraNoir,

Recommended Posts

I`m quite new to AutoIt, but from what I can tell, this should work, i`ve reworked something that was posted in these forums.

$User = InputBox("Messenger", "Enter the name of the Computer to Send a message to.")
   If Not @error And $Computer Then ; Not error and $Computer nneds to be something to be valid
      $Time = InputBox("Messenger", "Enter the number of seconds you wish the message to display.")
      If Not @error And $Time Then ; Not error and $Time needs to be something to be valid
         $Message = InputBox("Messenger", "Please type your message now.")
         If Not @error Then ; Not error and no message can be valid?
            ;$msg = "C:\Windows\System32\msg.exe"
            RunWait('"' & @ComSpec & '" /c  msg $User "/server:' & '" "/Time:' & $Time & '" "' & $Message & '"')
         EndIf
      EndIf
   EndIf

This was the solution to the problem, except that i wanted to send to Users instead of computers, so I used $User and put it instead of the * for every user.

For whatever reason its still not working.

This was the original script posted which didn`t work either once I changed for $User

;Changes to this part do the following: InputBoxes will time out after 2 minutes. If you press 'Cancel' or don't include a value then the message will
;not send. 30 is set as the default message duration
Local $Computer = InputBox("Messenger", "Enter the name of the Computer to Send a message to.", "", Default, Default, Default, Default, Default, 120)
If @error Or Not $Computer Then Exit

Local $Time = InputBox("Messenger", "Enter the number of seconds you wish the message to display.", "30", Default, Default, Default, Default, Default, 120)
If @error Or Not $Time Then Exit

Local $Message = InputBox("Messenger", "Please type your message now.", "", Default, Default, Default, Default, Default, 120))
If @error Or Not $Message Then Exit
    
;Run the command, capturing any output from the program
Local $msg_exe = "C:\Windows\System32\msg.exe"
Local $Debug = RunGetText( @comspec & " /c " & $msg_exe & " * /server:" & $Computer & " /Time:" & $Time & " " & $Message, Default, @SW_HIDE, 60*3)

;Write any output to the console for debugging
ConsoleWrite ($Debug)

;$command = full path to the exe
;$workingDir = full path of working directory
;$showFlag = passes value directly to Run() command, see Run() documentation
;$timeOut = time before expiring in seconds
Func RunGetText ($command, $workingDir, $showFlag, $timeOut)
    $timeOut *= 1000
    Local $pid = Run ($command, $workingDir, $showFlag, 0x8)
    Local $returnText
    
    For $i = 0 to 5
        Local $startTime = TimerInit ()
        While 1
            Local $temp = StdoutRead ($pid)
            If @error Then ExitLoop
            $returnText &= $temp
        
            If TimerDiff ($startTime) > $timeOut Then
                StdioClose ($pid)
                $returnText = ""
                ExitLoop
            EndIf
        WEnd
        If $returnText Then ExitLoop
    Next
    
    Return $returnText
EndFunc

If someone could point out what i`m doing wrong, i`d be delighted.

Have a nice day

Link to comment
Share on other sites

  • Moderators

Instead of this:

RunWait('"' & @ComSpec & '" /c  msg $User "/server:' & '" "/Time:' & $Time & '" "' & $Message & '"')

Try this:

RunWait('"' & @ComSpec & '" /c  msg ' & $User & '"/server:' & '" "/Time:' & $Time & '" "' & $Message & '"')

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

$User = InputBox("Messenger", "Enter the name of the User to Send a message to.")
   If Not @error And $User Then ; Not error and $User needs to be something to be valid
      $Time = InputBox("Messenger", "Enter the number of seconds you wish the message to display.")
      If Not @error And $Time Then ; Not error and $Time needs to be something to be valid
         $Message = InputBox("Messenger", "Please type your message now.")
         If Not @error Then ; Not error and no message can be valid?
            ;$msg = "C:\Windows\System32\msg.exe"
               RunWait( @ComSpec & " /c " & " msg " & $User & $Message )
         EndIf
      EndIf
   EndIf

This is my latest try, it now pop up a command prompt and says

Enter message to send; end message by pressing CTRL-Z on a new line, then ENTER

 

Link to comment
Share on other sites

  • Moderators

Try changing the /c in your RunWait line to /k, so you can see what is being typed out. It sounds like you're missing a space between the $User and $Message.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

Since you have to have Message special access permission, have you confirmed this works for you when you do it manually?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Yes im on Server 2008, it works perfectly (The Syntax does and rights not the script itself)

syntax is usually ( msg administrator test )

This will popup the test msg for that account

it also works straight from the RUN command in windows with the exact same syntax as above.

Thanks a lot for all the help btw

 

Edit:  What I mean is that it doesn't work still, same issue as before

Edited by MiraNoir
Link to comment
Share on other sites

  • Solution

$User = InputBox("Messenger", "Utilisateur: (Prenom.Nom)                         Domaine: (*)")
   If Not @error And $User Then ; Not error and $User needs to be something to be valid
         $Message = InputBox("Messenger", "Entrer Votre Message:")
         If Not @error Then ; Not error and no message can be valid?
            ;$msg = "C:\Windows\System32\msg.exe"
               RunWait( @ComSpec & " /c  msg " & $User & " " &  $Message )
         EndIf
      EndIf

This Fixed it, it was indeed a space needed, thus why it prompted that way. Thanks a lot for the help.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...