J'ai créé ce script pour envoyer des messages (MsgBox) à des ordinateurs dans votre réseau.
Nom: EasySender
Version courant: 1.0
Licence: Code source libre
Fonctionnement:
- Biensûr, votre compte doit être dans le groupe administrateurs sur le poste distant.
- Le script upload le message (msg.ini) sur le poste distant, ainsi que le script DisplayMsg.exe, qui fait afficher le message.
- Ensuite, le script execute psexec.exe pour lancer le script DisplayMsg.exe à distance sur le poste distant, ce qui provoque l'affichage du message.
Je continue à améliorer ce script pour ajouter de nouvelles fonctionnalités, et n'hésitez pas à me proposer des idées d'améliorations ou des corrections de bug à cette adresse: riouxjo@gmail.com
Téléchargez le script ici: http://www.mediafire.com/file/dguelddxm ... Sender.zip
Voici le code source pour les intéressés:
► Afficher le texteEasySender
Code : Tout sélectionner
#include <GuiEdit.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <TabConstants.au3>
IniReadSectionNames("options.ini")
If @error Then
IniWrite("options.ini","Options","titre","")
EndIf
$MainForm = GUICreate("EasySender", 471, 306, 234, 158)
$Menu = GUICtrlCreateMenu("Options")
$Options = GUICtrlCreateMenuItem("Préférences", $Menu)
$aPropos = GUICtrlCreateMenuItem("À propos", $Menu)
$nomInput = GUICtrlCreateInput("", 112, 8, 121, 21, BitOR($ES_UPPERCASE,$ES_AUTOHSCROLL))
$titreInput = GUICtrlCreateInput("", 112, 40, 329, 21)
$editBox = GUICtrlCreateEdit("", 112, 72, 329, 129)
$Radio1 = GUICtrlCreateRadio("Prochaine ouverture de session", 125, 216, 170, 17)
$Radio2 = GUICtrlCreateRadio("Maintenant", 320, 216, 80, 17)
$Label1 = GUICtrlCreateLabel("Ordinateur :", 32, 8, 74, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Message :", 40, 72, 66, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("Script en cours d'execution...", 112, 256, 141, 17)
GUICtrlSetColor(-1, 0x008000)
$Envoyer = GUICtrlCreateButton("Envoyer", 280, 248, 75, 25, $WS_GROUP)
$Fermer = GUICtrlCreateButton("Fermer", 368, 248, 75, 25, $WS_GROUP)
$Label4 = GUICtrlCreateLabel("Affichage :", 40, 216, 66, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label5 = GUICtrlCreateLabel("Titre :", 64, 40, 38, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUISetState()
debut()
Func about()
$About = GUICreate("À propos", 324,241,277,163)
$GroupBox1 = GUICtrlCreateGroup("", 8, 8, 305, 185)
$Image1 = GUICtrlCreatePic(@ScriptDir & "\logo.gif", 16, 24, 113, 81)
$Label1 = GUICtrlCreateLabel("EasySender", 152, 24, 117, 28, $WS_GROUP)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x316AC5)
$Label2 = GUICtrlCreateLabel("Version :", 152, 56, 54, 17, $WS_GROUP)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label4 = GUICtrlCreateLabel("Logiciel pour envoyer des messages", 96, 152, 175, 17, $WS_GROUP)
$Label3 = GUICtrlCreateLabel("Copyright :", 16, 128, 65, 17, $WS_GROUP)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label5 = GUICtrlCreateLabel("Description :", 16, 152, 76, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label6 = GUICtrlCreateLabel("à des ordinateurs distants.", 96, 168, 127, 17)
$Label7 = GUICtrlCreateLabel("Logiciel et code source libre.", 96, 128, 139, 17)
$Label8 = GUICtrlCreateLabel("1.0", 216, 56, 19, 17)
$Label9 = GUICtrlCreateLabel("Créé par Jonathan Rioux", 152, 80, 144, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label10 = GUICtrlCreateLabel("riouxjo@gmail.com", 152, 96, 92, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$OK = GUICtrlCreateButton("&OK", 128, 208, 75, 25)
GUISetState(@SW_SHOW, $About)
GUISetState(@SW_DISABLE, $MainForm)
While 1
$aMsg = GUIGetMsg()
Select
Case $aMsg=$GUI_EVENT_CLOSE Or $aMsg=$OK
GUISetState(@SW_ENABLE, $MainForm)
GUISwitch($MainForm)
GUIDelete($About)
Return
EndSelect
WEnd
EndFunc
Func preferences()
$Preferences = GUICreate("Préférences", 413, 305, 270, 180)
$PageControl1 = GUICtrlCreateTab(8, 8, 396, 256)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
GUICtrlCreateTabItem("Général")
$Label1 = GUICtrlCreateLabel("Titre par défaut :", 32, 56, 84, 18)
$titreDefaut = GUICtrlCreateInput("", 120, 53, 265, 22)
GUICtrlCreateTabItem("")
$OK = GUICtrlCreateButton("&OK", 246, 272, 75, 25, $WS_GROUP)
$Annuler = GUICtrlCreateButton("Annuler", 326, 272, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW, $Preferences)
GUISetState(@SW_DISABLE, $MainForm)
$titreIni=IniRead("options.ini","Options","titre","")
GUICtrlSetData($titreDefaut,$titreIni)
While 1
$pMsg = GUIGetMsg()
Select
Case $pMsg=$GUI_EVENT_CLOSE Or $pMsg=$Annuler
GUISetState(@SW_ENABLE, $MainForm)
GUISwitch($MainForm)
GUIDelete($Preferences)
Return
Case $pMsg=$OK
$titre=GUICtrlRead($titreDefaut)
IniWrite("Options.ini","Options","titre",$titre)
GUISetState(@SW_ENABLE, $MainForm)
GUISwitch($MainForm)
GUIDelete($Preferences)
Return
EndSelect
WEnd
EndFunc
Func debut()
$titreIni=IniRead("options.ini","Options","titre","")
GUICtrlSetData($titreInput,$titreIni)
GUICtrlSetState($Envoyer, $GUI_ENABLE)
GUICtrlSetState($Fermer, $GUI_ENABLE)
GUICtrlSetState($Label3, $GUI_HIDE)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
GUIDelete()
Exit
Case $Envoyer
GUICtrlSetState($Envoyer, $GUI_DISABLE)
GUICtrlSetState($Fermer, $GUI_DISABLE)
$nomInfo = GUICtrlRead($nomInput)
$titre = GUICtrlRead($titreInput)
$msg = GUICtrlRead($editBox)
If $msg=="" Then
MsgBox(0,"Erreur","Message vide.")
debut()
EndIf
If Ping($nomInfo,4000) Then
GUICtrlSetState($Label3, $GUI_SHOW)
$msg = StringReplace($msg, @CRLF, "\CR\")
If DirGetSize("\\" & $nomInfo & "\c$\temp")==-1 Then
DirCreate("\\" & $nomInfo & "\c$\temp")
EndIf
$path = "\\" & $nomInfo & "\c$\temp\msg.ini"
IniWrite($path,"Message","1",$titre)
IniWrite($path,"Message","2",$msg)
FileCopy("DisplayMsg.exe", "\\" & $nomInfo & "\c$\temp\")
If BitAND(GUICtrlRead($Radio1), $GUI_CHECKED)==$GUI_CHECKED Then
FileCopy("DisplayMsg.exe", "\\" & $nomInfo & "\c$\Documents and Settings\All Users\Menu Démarrer\Programmes\Démarrage\")
MsgBox(0,"Info","Le message apparaîtra à la prochaine" & @CR & "ouverture de session du " & $nomInfo)
ElseIf BitAND(GUICtrlRead($Radio2), $GUI_CHECKED)==$GUI_CHECKED Then
RunWait("psexec.exe -i -d \\" & $nomInfo & " c:\temp\DisplayMsg.exe")
Else
MsgBox(48,"Erreur","Veuillez choisir un mode d'affichage")
EndIf
debut()
Else
MsgBox(0,"Erreur","Nom info n'existe pas ou n'est pas disponible")
debut()
EndIf
Case $aPropos
about()
debut()
Case $Options
preferences()
debut()
Case $Fermer
GUIDelete()
Exit
EndSwitch
WEnd
EndFunc
Version 1.0 (22 juillet 2009)
- Présentation du script à la communauté
- Fonctionnalités de base