COMO FAZER UM SHUTDOWN COM UM AVISO EM REDE
COMO FAZER UM SHUTDOWN COM UM AVISO EM REDE? O problema é que o negócio é pra Windows 7 , e windows 7 não mostra aquele aviso igual no XP. Alguma ideia?
Tem uma maneira de usar o SendMenseger do Windows
NET SEND {name | * | /DOMAIN[:name] | /USERS} message
name Can be user name, PC name, or messaging name to send the message to. If the name is a computer name that contains blank characters, it need to be enclosed the alias in quotation marks ([Ô] [Ô]).
* Sends the message to all the names in your group.
/DOMAIN[:name] Sends the message to all the names in the workstation domain. If name is specified, the message is sent to all the names in the specified domain or workgroup.
/USERS Sends the message to all users connected to the server.
message Is text to be sent as a message.
NET SEND examples
To send a broadcast message to another user: NET SEND anna_81 See you soon, bye.
To send a message to all users who have a session with the server: NET SEND /USERS Shutdown all computers, please.
To send a broadcast message to the whole domain: NET SEND * This server will shut down in 5 minutes.
Shell [Ô] NET SEND /USERS Shutdown all computers, please.[Ô]
NET SEND {name | * | /DOMAIN[:name] | /USERS} message
name Can be user name, PC name, or messaging name to send the message to. If the name is a computer name that contains blank characters, it need to be enclosed the alias in quotation marks ([Ô] [Ô]).
* Sends the message to all the names in your group.
/DOMAIN[:name] Sends the message to all the names in the workstation domain. If name is specified, the message is sent to all the names in the specified domain or workgroup.
/USERS Sends the message to all users connected to the server.
message Is text to be sent as a message.
NET SEND examples
To send a broadcast message to another user: NET SEND anna_81 See you soon, bye.
To send a message to all users who have a session with the server: NET SEND /USERS Shutdown all computers, please.
To send a broadcast message to the whole domain: NET SEND * This server will shut down in 5 minutes.
Shell [Ô] NET SEND /USERS Shutdown all computers, please.[Ô]
só tem um problema , o net send nao existe no w7
Só chamar o shutdown..
Shell([Ô]shutdown -s -m \\IP-DO-COMPUTADOR /c Seu computador sera desligado em tantos minutos.[Ô])
Shell([Ô]shutdown -s -m \\IP-DO-COMPUTADOR /c Seu computador sera desligado em tantos minutos.[Ô])
mas eu ja comecei falando que o Shutdown no W7 não mostra algo decente ele so mostra um balao queria algo que chamasse a atenção , pô ngm sabe?
Como assim chamar atenção ?
Tipo uma janala piscando ?
Tipo uma janala piscando ?
veja
http://www.howtogeek.com/howto/windows-vista/quick-tip-create-shutdown-restart-lock-icons-in-windows-vista/
veja se a alternativa te agrada
http://www.howtogeek.com/howto/windows-vista/quick-tip-create-shutdown-restart-lock-icons-in-windows-vista/
veja se a alternativa te agrada
A janela de desligamento do sistema é padrão,a nao ser que voce crie um server que trabalhe com tcp/ip e mande um comando pra ele,e o mesmo comece a piscar
Exato ! O que daria pra você fazer é criar um aplicação mas acho que dai teria que fazer via socket, CLIENTE X SERVIDOR.
Ola amigo Pietro, estive aproveitando minha folga para calar minhas curiosidades, pesquizando na net encontrei uma soluçao do seu problema!
O codigo abaixo detecta as mensagens do NET SEND, poderia com isso ativar um janela em cada host cliente quando o program monitor encontra ulguma mensagens especifica do pc de comando, quase a mesma coisa de um server enviando a um host monitor, só que aqui pediria apenas o net send para enviar...
Option Explicit
[ô]*******************************************************************
[ô]* *
[ô]* capture net send written by morsnowski *
[ô]* *
[ô]* many people have asked how to capture net send messages and i *
[ô]* got kind of sick of that question. this example shows one way *
[ô]* to collect incoming messages. its using a timer to check for *
[ô]* window caption of the messenger service. this is most likely *
[ô]* not the most elegant way to do it but at least its not *
[ô]* disturbing or interfering with the OS. i[ô]ve put a few comments *
[ô]* the code. if you still have question please post them on *
[ô]* *
[ô]* Xtremevbtalk.com *
[ô]* *
[ô]* and don[ô]t PM me. *
[ô]* *
[ô]* you need 4 command buttons, one textbox (multiline and locked), *
[ô]* one timer and a form, the copy and paste this stuff into your *
[ô]* code window. this example is meant to be copy and paste *
[ô]* friendly that[ô]s why i didn[ô]t use proper naming convention for *
[ô]* the controls, in case you were wondering. *
[ô]*******************************************************************
Dim tHWnd As Long
Dim txtWnd As Long
Dim btnWnd As Long
Dim lTargetButton As Long
Dim lngText As Long
Dim strMessage As String
Dim strTarget As String
Dim strStaticTarget As String
Dim strButtonTarget As String
Private Declare Function FindWindow Lib [Ô]user32[Ô] Alias [Ô]FindWindowA[Ô] (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib [Ô]user32[Ô] Alias [Ô]FindWindowExA[Ô] (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function GetWindowTextLength Lib [Ô]user32[Ô] Alias [Ô]GetWindowTextLengthA[Ô] (ByVal hwnd As Long) As Long
Private Declare Function GetWindowText Lib [Ô]user32[Ô] Alias [Ô]GetWindowTextA[Ô] (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindowLong Lib [Ô]user32[Ô] Alias [Ô]GetWindowLongA[Ô] (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SendMessage Lib [Ô]user32[Ô] Alias [Ô]SendMessageA[Ô] (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_COMMAND As Long = &H111
Private Const GWL_ID As Long = -12
Private Sub Form_Load()
[ô]lets initialze some vars
Timer1.Enabled = False
Timer1.Interval = 200 [ô]the interval is up to you 200 milisecs is working fine for me
[ô]if your machine is old and rusty set it a little higher
strTarget = [Ô]Messenger Service [Ô] [ô]please notice that there is a SPACE at the end of the string
[ô]it[ô]s not working without
strStaticTarget = [Ô]Static[Ô] [ô]this the classname or the actual [Ô]text window[Ô]
strButtonTarget = [Ô]Button[Ô] [ô]well ...
Command1.Caption = [Ô]listen[Ô]
Command2.Caption = [Ô]stop[Ô]
Command2.Enabled = False
Command3.Caption = [Ô]exit[Ô]
Command4.Caption = [Ô]clear[Ô]
Me.Caption = [Ô]capture net send[Ô]
Text1.Text = [Ô][Ô]
End Sub
Private Sub Command1_Click()
[ô] well i hope this explains itself !
Timer1.Enabled = True
Me.Caption = [Ô]capture net send / listening[Ô]
Command1.Enabled = False
Command2.Enabled = True
End Sub
Private Sub Command2_Click()
[ô]just the same as above
Timer1.Enabled = False
Me.Caption = [Ô]capture net send / not listening[Ô]
Command1.Enabled = True
Command2.Enabled = False
End Sub
Private Sub Command4_Click()
[ô]again easy stuff
Text1.Text = [Ô][Ô]
End Sub
Private Sub Command3_Click()
[ô]no comment on that
Unload Me
End Sub
Private Sub checkNet()
[ô]okay i[ô]ve taken all dims out of this function because i just don[ô]t want
[ô]to reinitialse them every 200 ms.
tHWnd = FindWindow(vbNullString, strTarget) [ô]lets see if there is a messenger window somewhere
DoEvents
If tHWnd <> 0 Then [ô]in case we find one we will work with it if not thats it for this turn
txtWnd = FindWindowEx(tHWnd, 0, strStaticTarget, vbNullString) [ô]since there is a messenger
[ô]window there has to be a
[ô]textwindows as well
lngText = GetWindowTextLength(txtWnd) + 1 [ô]not much to say just the length of the text
strMessage = String(lngText, [Ô] [Ô]) [ô]lets create a buffer string of the exact length to contain the text
GetWindowText txtWnd, strMessage, lngText [ô]stuff the window text into the buffer
Text1.Text = Text1.Text & vbCrLf & [Ô]************************[Ô] & vbCrLf & strMessage [ô]and display it
[ô]if you dont like the way its done above just change it and leave me alone
btnWnd = FindWindowEx(tHWnd, 0, strButtonTarget, vbNullString) [ô]we need the handle of the ok button
[ô]in order to click it
lTargetButton = GetWindowLong(btnWnd, GWL_ID) [ô]thats another pram we need to click that button
SendMessage tHWnd, WM_COMMAND, lTargetButton, btnWnd [ô]time to get rid of the message
[ô]this stuff is not strictly required but i like to know what the vars contain
tHWnd = vbNull
txtWnd = vbNull
btnWnd = vbNull
lTargetButton = vbNull
lngText = vbNull
strMessage = [Ô][Ô]
End If
End Sub
Private Sub Timer1_Timer()
[ô]just a call for our checking routine
checkNet
End Sub
O codigo abaixo detecta as mensagens do NET SEND, poderia com isso ativar um janela em cada host cliente quando o program monitor encontra ulguma mensagens especifica do pc de comando, quase a mesma coisa de um server enviando a um host monitor, só que aqui pediria apenas o net send para enviar...
Option Explicit
[ô]*******************************************************************
[ô]* *
[ô]* capture net send written by morsnowski *
[ô]* *
[ô]* many people have asked how to capture net send messages and i *
[ô]* got kind of sick of that question. this example shows one way *
[ô]* to collect incoming messages. its using a timer to check for *
[ô]* window caption of the messenger service. this is most likely *
[ô]* not the most elegant way to do it but at least its not *
[ô]* disturbing or interfering with the OS. i[ô]ve put a few comments *
[ô]* the code. if you still have question please post them on *
[ô]* *
[ô]* Xtremevbtalk.com *
[ô]* *
[ô]* and don[ô]t PM me. *
[ô]* *
[ô]* you need 4 command buttons, one textbox (multiline and locked), *
[ô]* one timer and a form, the copy and paste this stuff into your *
[ô]* code window. this example is meant to be copy and paste *
[ô]* friendly that[ô]s why i didn[ô]t use proper naming convention for *
[ô]* the controls, in case you were wondering. *
[ô]*******************************************************************
Dim tHWnd As Long
Dim txtWnd As Long
Dim btnWnd As Long
Dim lTargetButton As Long
Dim lngText As Long
Dim strMessage As String
Dim strTarget As String
Dim strStaticTarget As String
Dim strButtonTarget As String
Private Declare Function FindWindow Lib [Ô]user32[Ô] Alias [Ô]FindWindowA[Ô] (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib [Ô]user32[Ô] Alias [Ô]FindWindowExA[Ô] (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function GetWindowTextLength Lib [Ô]user32[Ô] Alias [Ô]GetWindowTextLengthA[Ô] (ByVal hwnd As Long) As Long
Private Declare Function GetWindowText Lib [Ô]user32[Ô] Alias [Ô]GetWindowTextA[Ô] (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindowLong Lib [Ô]user32[Ô] Alias [Ô]GetWindowLongA[Ô] (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SendMessage Lib [Ô]user32[Ô] Alias [Ô]SendMessageA[Ô] (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_COMMAND As Long = &H111
Private Const GWL_ID As Long = -12
Private Sub Form_Load()
[ô]lets initialze some vars
Timer1.Enabled = False
Timer1.Interval = 200 [ô]the interval is up to you 200 milisecs is working fine for me
[ô]if your machine is old and rusty set it a little higher
strTarget = [Ô]Messenger Service [Ô] [ô]please notice that there is a SPACE at the end of the string
[ô]it[ô]s not working without
strStaticTarget = [Ô]Static[Ô] [ô]this the classname or the actual [Ô]text window[Ô]
strButtonTarget = [Ô]Button[Ô] [ô]well ...
Command1.Caption = [Ô]listen[Ô]
Command2.Caption = [Ô]stop[Ô]
Command2.Enabled = False
Command3.Caption = [Ô]exit[Ô]
Command4.Caption = [Ô]clear[Ô]
Me.Caption = [Ô]capture net send[Ô]
Text1.Text = [Ô][Ô]
End Sub
Private Sub Command1_Click()
[ô] well i hope this explains itself !
Timer1.Enabled = True
Me.Caption = [Ô]capture net send / listening[Ô]
Command1.Enabled = False
Command2.Enabled = True
End Sub
Private Sub Command2_Click()
[ô]just the same as above
Timer1.Enabled = False
Me.Caption = [Ô]capture net send / not listening[Ô]
Command1.Enabled = True
Command2.Enabled = False
End Sub
Private Sub Command4_Click()
[ô]again easy stuff
Text1.Text = [Ô][Ô]
End Sub
Private Sub Command3_Click()
[ô]no comment on that
Unload Me
End Sub
Private Sub checkNet()
[ô]okay i[ô]ve taken all dims out of this function because i just don[ô]t want
[ô]to reinitialse them every 200 ms.
tHWnd = FindWindow(vbNullString, strTarget) [ô]lets see if there is a messenger window somewhere
DoEvents
If tHWnd <> 0 Then [ô]in case we find one we will work with it if not thats it for this turn
txtWnd = FindWindowEx(tHWnd, 0, strStaticTarget, vbNullString) [ô]since there is a messenger
[ô]window there has to be a
[ô]textwindows as well
lngText = GetWindowTextLength(txtWnd) + 1 [ô]not much to say just the length of the text
strMessage = String(lngText, [Ô] [Ô]) [ô]lets create a buffer string of the exact length to contain the text
GetWindowText txtWnd, strMessage, lngText [ô]stuff the window text into the buffer
Text1.Text = Text1.Text & vbCrLf & [Ô]************************[Ô] & vbCrLf & strMessage [ô]and display it
[ô]if you dont like the way its done above just change it and leave me alone
btnWnd = FindWindowEx(tHWnd, 0, strButtonTarget, vbNullString) [ô]we need the handle of the ok button
[ô]in order to click it
lTargetButton = GetWindowLong(btnWnd, GWL_ID) [ô]thats another pram we need to click that button
SendMessage tHWnd, WM_COMMAND, lTargetButton, btnWnd [ô]time to get rid of the message
[ô]this stuff is not strictly required but i like to know what the vars contain
tHWnd = vbNull
txtWnd = vbNull
btnWnd = vbNull
lTargetButton = vbNull
lngText = vbNull
strMessage = [Ô][Ô]
End If
End Sub
Private Sub Timer1_Timer()
[ô]just a call for our checking routine
checkNet
End Sub
Tópico encerrado , respostas não são mais permitidas