Advertisement
Werezwolf

CMD Domain Messager

Jul 31st, 2014
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.31 KB | None | 0 0
  1. ::This Script is to send domain user/s a message
  2. ::Requires elevation and drive mappings
  3. ::http://pastebin.com/6bawWDUs
  4.  
  5. @Echo off
  6. SET count=0
  7. Set xdate=%date:~-4,4%%date:~-7,2%%date:~-10,2%
  8. Set return=^& echo.
  9. NET USE X: %xdrive% /PERSISTENT:No
  10. set location=X:\Path\To\Destination
  11. cd /d %location%
  12. @mkdir %location%\Logs\Messaging\%xdate%
  13. set log=%location%\Logs\Messaging\%xdate%\history.txt
  14.  
  15. CHOICE /C:YNQ /N /D Q /T 35 /m "Message All User? [Y]yes or [N]No"
  16. goto s_routine_%ERRORLEVEL%
  17.  
  18. :s_routine_1
  19. ::Message All Users
  20. SET /P query_Msg=What do you want to say?
  21. ::For Each Domain Computer
  22. FOR /D %%p IN ('%location%\Logs\ComputerInventory') DO (
  23. msg * /SERVER:%%p "%query_Msg% ~From %xusername%"
  24. Set /a count+=1 )
  25. msg %xusername% "Message Sent:%query_Msg%"
  26. Pause  
  27. goto s_routine_3
  28.  
  29. :s_routine_2
  30. ::Message an User
  31. net user /domain
  32. SET /P query_User=What Username do you want to send to?
  33. SET /P query_Msg=What do you want to say?
  34. ::For Each Domain Computer Message the Specific User
  35. FOR /D %%p IN ('%location%\Logs\ComputerInventory') DO (
  36. msg %query_User% /SERVER:%%p "%query_Msg% ~From %xusername%"
  37. Set /a count+=1 )
  38. msg %xusername% "Message Sent:%query_Msg% to %query_User%"
  39.  
  40. :s_routine_3
  41. (echo %time%:   %xusername%@%computername% Sent %query_Msg% to %query_User% %count%%return%) >> %log%
  42. Exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement