sábado, 13 de agosto de 2011

Homenagem aos Pais | A Tribute to the fathers



PortuguêsEnglish


Pai,

Ele é a referência,

Ele é a coluna principal da família,

Ele é a força e o amor unidos,

E neste dia todo especial,

Deixo minha homenagem a você,

Que ajuda a formar a geração do futuro,

Parabéns pelo seu dia.

Feliz dia dos Pais!




Father,

He is the reference,

He is the main pillar of the family,

He is strength and love together,

And on this special day,

I leave my tribute to you,

Who helps to form the future generations,

Congratulations for your day.

Happy Father's Day!



Por/By Pedro Lima

sexta-feira, 12 de agosto de 2011

A net messenger script for Windows 7/2008 | Um script mensageiro de rede para Windows 7/2008



ENGLISH ARTICLE (see also in portuguese):

INTRODUCTION:

It is well known to all of Windows 2008 and Windows 7 users the lack of the (or should I say late ?) "NET SEND" command. I don't know the exact reasons for Microsoft taking out this useful program from the administrator's options for sending messages to the network, but, the fact is that it is still needed, otherwise, there would not be so many people looking for it in internet.

After this brief explanation, I must say that there is no need to complain anymore. There is a substitute made in a simple script using the MSG command. If there is one thing I must say first, is that the MSG command was not intended to substitute NET SEND. It is just a feature to send messages to terminal users in the computer. I used it as a basis to mimic the late NET SEND, and I think the results were good.

So, let's show how to use the script.



THE FIRST DIALOG BOX "Type the message to be sent to network computer(s)":

This is quite easy to spot. Just type the message you want to be sent to your users here then press the ENTER key.



THE SECOND DIALOG BOX "Choose the right scope":

Here you are given three options:

1) Type * for all computers - If you type this option, you MUST be a member of a domain. Also, the user sending this message MUST be a member of the ADMINISTRATOR GROUP in EACH target system that is to receive the message.


You must do some work before using this tool in the domain. If you are executing the script now you can cancel its execution pressing the ESC key. So, to use this domain-wide you must be sure that a registry key is correctly set in EVERY machine joined in the domain. The best way to accomplish this is by using a GPO. Here I'll show every step that need to be taken before it's ready to go.

To make the GPO for your machines respond to the script, just open the 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\Terminal Server

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.

This setting will only be "activated" after the machines restart, because it is a computer policy that is processed only at boot time.


If you don't have a Windows 2008 domain to make this configuration, you can use the script called "enablemsg.vbs" included in this kit. You must execute this in EVERY machine that is to receive the messages, and in the case you must use the administrator account of every workstation to execute the script. It is needless to say that this script should ONLY be used if you don't have a domain available.

PS: Remember that this is not the "NET SEND" command. It is a "simulation" of it. So, if your domain contain thousands of computers then your script may take some time to process (it will try to send the message one by one), so it is not advisable to call this script from production servers. Instead, call it from any workstation in the domain, remembering to log on using an administrator account for the domain or an account that has administrative status on all workstations. 

2) The single computer name - This is the simplest way to use the script. Just type the name of the machine that you want the message to be send. You can even use "localhost" for test purposes.


3) A path to a file containing a list of computers like c:\list.txt. - This option is good for selecting only a number of machines to target the message, or in the case you don't have a domain and want to use this script for a small office. In this case, it is mandatory that the username logged in to call the script exists in every machine that will receive the message, and that the logon name has administrator status in all those machines. The file content must contain ONLY the machine names without spaces in the left of right side and terminated with the ENTER key in every line (not in the last). Remember to do not press ENTER in the last line, or the script may not process the file correctly. The other important observation to make is that the file path MUST BE complete. It MUST contain the : character so the variable can be correctly interpreted as a path to a file.


The content of the list is as the example bellow:

COMPUTER01
COMPUTER02
COMPUTER03


The script will read every line of the list and will send the network message to the computers listed in the file.



FINAL WORDS:

This script was made to address a specific need I had in the agency I work for. Since I saw no other free solution in the web, and saw many comments that sending messages to the network like we did with "NET SEND" was not possible with built-in windows tools (just with third-party paid software), I started to think and came out with this simple solution. It is a workaround, but it works pretty good, at least for the communication between windows 7 and windows 2008 computers. I hope that this script can be as useful to you as it is to me. If you liked it and want to improve the code, feel free to do it. Just remember to maintain the correct credits on the top of the script, inserting your modifications with comments in the part you will alter, putting in your name and improvements made. Let's spread this solution out. Any comments, use my blog to post it.

FECI QUOD POTUI, FACIANT MELIORA POTENTES!


Pedro Lima

PS: The script can be seen also in the TechNet repository at this link: http://gallery.technet.microsoft.com/scriptcenter/A-net-messenger-script-for-810f8331
tags for search engines: NET SEND, net send, MSG.exe, Windows 7, Windows 2008, Windows Vista, messenger service, serviço mensageiro, enviar mensagens, send messages, usuários da rede, network users.


Artigo em Português:

INTRODUÇÃO:

É conhecida por todos os usuários do Windows 2008 e Windows 7 a falta (ou devo dizer "morte" ?) do comando "NET SEND". Eu não sei as razões exatas para a Microsoft ter tirado este útil programa das opções que os administradores tinham para enviar mensagens na rede, mas, o fato é que ele ainda é necessário, pois do contrário não haveria tanta procura pelo mesmo na internet.

Depois dessa breve explanação, eu devo dizer que não há mais necessidade de reclamar esta ausência. Há um substituto feito através de um script simples usando o novo comando MSG. Se há algo que devo colocar primeiro é que o comando MSG não foi feito para substituir o NET SEND. É apenas um recurso para enviar mensagens aos usuários do serviço de terminal no computador. Usei o mesmo como base para imitar o "falecido" NET SEND, e acho que os resultados foram bons.

Então, vamos mostrar como usar o script.



A PRIMEIRA TELA "Digite a meensagem a ser enviada para o(s) computador(es) da rede":

Esta tela é bem fácil de entender. Apenas digite a mensagem que você quer enviar para seus usuários e pressione a tecla ENTER.



A SEGUNDA TELA "Escolha o escopo correto":

Aqui você tem três opções:

1) Digite * para todos os computadores - Se você digitar esta opção, você DEVE ser membro de um domínio. Além disso, o usuário que enviar esta mensagem PRECISA ser membro do grupo ADMINISTRADORES em CADA sistema que deve receber a mensagem.


Aqui você precisa fazer um trabalho antes de usar esta ferramenta no domínio. Se você estiver executando o script agora você pode cancelar sua execução pressionando a tecla ESC. Então, para usar o script em nível de domínio você precisa assegurar-se que uma chave do registro está corretamente configurada em CADA máquina inserida no domínio. A melhor forma de fazer isto é usando uma GPO. Aqui eu vou mostrar cada passo que deve ser feito antes que o script esteja pronto para rodar.

Para fazer a GPO a fim de que suas máquinas respondam ao script, abra o Console de Gerenciamento Diretivas de Grupo em: Ferramentas Administrativas / Gerenciamento de Diretiva de Grupo. Agora, clique com o botão direito do mouse na "Diretiva Padrão do Domínio" na raiz do domínio, e clique em "Editar". Navegue através da "Configuração do computador", "Preferências", "Configurações do Windows" e então abra "Registro". Agora crie um item de registro, clicando com o botão direito o nó "Registro" escolhendo em seguida a opção "Novo -> Item de Registro". Na seção "ação" escolha "substituir" e deixe a seleção na hive "HKEY_LOCAL_MACHINE" e no "Caminho da Chave", clique no botão "...". Escolha este caminho de chave:

SYSTEM\CurrentControlSet\Control\Terminal Server

Em "Nome do Valor", digite "AllowRemoteRPC" (sem as aspas mostradas aqui). No campo "tipo de valor" escolha "REG_DWORD", e no campo "dados do valor" digite "1" (sem as aspas). Escolha também a base como "hexadecimal" e clique em OK.

Esta configuração só será "ativada" após a reinicialização das máquinas, pois a política de computador só é processada após o boot.


SE você não tem um domínio Windows 2008 para fazer esta configuração, você pode usar um script chamado "enablemsg.vbs" incluído neste kit. Você deve executar este script em CADA máquina que deve receber as mensagens, e neste caso você precisa usar uma conta de administrador de cada estação para executar o script. É desnecessário dizer que este script só deve ser usado se você NÂO TIVER um domínio disponível.

OBS: Lembre-se que isto não é comando "NET SEND". É uma "simulação" dele. Assim, se o seu domínio contém milhares de computadores o script levará um tempo para processar (e o fará computador a computador) não sendo aconselhável chamar o script a partir de servidores de produção. Ao invés disso, chame-o de qualquer outra estação no domínio, lembrando de se logar com uma conta de administrador no domínio em questão ou de uma conta que tenha status de administrador nas estações do domínio. 

2) Um único nome de computador - Esta é a maneira mais simples de usar o script. Apenas digite o nome da máquina que você quer que a mensagem seja enviada. Você pode até usar "localhost" para propósito de testes.


3) Um caminho para um arquivo contendo uma lista de computadores como c:\list.txt. - Esta opção é boa para selecionar apenas um número de máquinas para serem alvo da mensagem, ou no caso de você não ter um domínio e quiser usar este script para um escritório pequeno. Neste caso, é OBRIGATÓRIO que o nome do usuário (logon) logado na máquina usada para chamar o script exista em cada máquina que irá receber a mensagem, e que o nome de logon tenha status de administrador em todas as máquinas. O conteúdo do arquivo precisa conter APENAS os nomes das máquinas sem espaços nos lados direito e esquerdo e terminados com a tecla ENTER em cada linha (não na última). Lembre-se de não pressionar ENTER na última linha, ou o script pode não processar o arquivo corretamente. Outra observação importante a fazer é que o caminho do arquivo PRECISA SER completo. Ele TEM de conter o caractere : para que a variável possa ser corretamente interpretada como um caminho para um arquivo.


O conteúdo da lista deverá ser como no exemplo abaixo:

COMPUTADOR01
COMPUTADOR02
COMPURADOR03


O script irá ler cada linha e irá mandar uma mensagem de rede para os computadores listados no arquivo.



CONSIDERAÇÕES FINAIS:

Este script foi feito para responder a uma necessidade específica que tive no órgão público onde trabalho. Visto que não vi nenhuma solução gratuita na web, e vi muitos comentários dizendo que enviar mensagens pela rede como fazíamos com o "NET SEND" não era mais possível com as ferramentas embutidas do Windows (apenas com software de terceiros - e pago), eu comecei a pensar e desenhei esta solução simples. É um, digamos, workaround (para usar uma palavra bonita), mas funciona muito bem, pelo menos para comunicação entre computadores com Window 7 e Windows 2008 (e até Vista). Eu espero que este script possa ser tão útil para você quanto tem sido para mim. Se você gostou e quer melhorar o código, sinta-se à vontade para fazer isto. Só se lembre de manter os créditos corretos no topo do script, inserindo suas modificações com comentários na parte que você vai alterar, colocando seu nome e os melhoramentos feitos (ou até me mandar para que eu incorpore o código). Vamos espalhar a solução! Qualquer comentário, use meu blog para postar, ou as perguntas no repositório da technet.

FECI QUOD POTUI, FACIANT MELIORA POTENTES!


Pedro Lima

OBS: Este script também pode ser visto no repositório do Microsoft TechNet neste link (é hoje o mais popular na categoria "Mensagens e Comunicação"): http://gallery.technet.microsoft.com/scriptcenter/A-net-messenger-script-for-810f8331
tags for search engines: NET SEND, net send, MSG.exe, Windows 7, Windows 2008, Windows Vista, messenger service, serviço mensageiro, enviar mensagens, send messages, usuários da rede, network users.