Blog do Cláudio Gonçalves

Scripts

How Can I Install Fonts Using a VBScript / command line / batch file? Como posso instalar fontes usando um script/linha de comando?

by Cláudio Roberto Gonçalves on Sep.07, 2010, under Principal, Scripting, Scripts

É incrivel as coisas que são solicitadas aos IT para fazerem, mas ainda bem que existe o “Tio Google” não é!!??

Então a pergunta é:

How Can I Install Fonts Using a VBScript / command line / batch file? Como posso instalar fontes usando um script/linha de comando?

Na verdade quando instala-se uma Font no Computador o que ele faz é copiar para “%systemroot%\fonts” (sem aspas) e actualizar a chave no Registry “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts“.

Isto pode ser automatizado, e principalemte quando se quer fazer o deploy em muitos computadores.

Encontrei duas soluções diferentes e aqui coloco para quem precisar:

Primeiro o VBS:

Const FONTS = &H14&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(FONTS)
objFolder.CopyHere "C:\Scripts\Myfont.ttf"

Depois a Linha de comando:

Rem fontinst.bat
copy
Myfont.ttf
%systemroot%\fonts
regedit
/s font.reg

e o Ficheiro font.reg deverá ter o seguinte texto

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts]

“Akbar Plain (TrueType)”=”Myfont.ttf

Share with SociBook.com

Leave a Comment :, , , , , , , , , , , , , , more...

VBS Dialog Box for Selecting Files

by Cláudio Roberto Gonçalves on May.19, 2010, under Scripting, Scripts

Desde que entrei neste mundo de Scripting uma das coisas que me às vezes chateia é ter que correr um script para vários servidores, e faço isso recorrendo a um ficheiro de texto (um exemplo). E sempre que tenho que o executar tenho que redefinir o caminho no código.

é então que encontrei este pequeno script que cria uma Dialog Box e onde podemos definir o tipo de ficheiro a ser seleccionado.

OBS: Só funciona no XP

mais info em http://blogs.technet.com/heyscriptingguy/archive/2005/03/01/how-can-i-use-a-multi-select-dialog-box-in-a-script.aspx

Set objDialog = CreateObject("UserAccounts.CommonDialog")
objDialog.Filter = "VBScript Scripts|*.vbs|All Files|*.*"
objDialog.Flags = &H0200
objDialog.FilterIndex = 1
objDialog.InitialDir = "C:folder"
intResult = objDialog.ShowOpen
If intResult = 0 Then
    Wscript.Quit
Else
    Wscript.Echo objDialog.FileName
End If

Share with SociBook.com

Leave a Comment more...

NETSH.exe

by Cláudio Roberto Gonçalves on Feb.18, 2010, under Scripts, Tecnologia

Netsh.exe é um utilitário da linha de comando que permite, local ou remotamente, exibir ou modificar a configuração de rede de um computador ligado.

Netsh.exe também oferece um recurso de script que permite que se execute um grupo de comandos batch. Com Netsh.exe também pode-se salvar um script de configuração em um arquivo de texto para fins de arquivo ou para ajudar a configurar outros servidores.

Netsh.exe está disponível no Windows 2000, Windows XP e Windows Server 2003.

Você pode usar a ferramenta Netsh.exe para executar as seguintes tarefas:

  • Configurar interfaces
  • Configurar os protocolos de roteamento
  • Configurar filtros
  • Configurar rotas
  • Configurar o comportamento de acesso remoto para Windows baseado em routers na qual esteja a correr o serviço  Routing and Remote Access Server (RRAS) Service
  • Mostrar a configuração do router em qualquer computador
  • Use o recurso de script para executar um conjunto de comandos em batch num router.

Share with SociBook.com

Leave a Comment more...

Criar uma Scope no DHCP usando um *.bat

by Cláudio Roberto Gonçalves on Jan.15, 2010, under Scripting, Scripts, Tecnologia

Por uma questão de trabalho, precisei procurar criar um Script que criasse uma Scope num servidor de DHCP de forma automática e sem erros.

Pra já este script o que fará é

1º Definir um Ip estático no Servidor (192.168.20.1);

2ºCriar uma Scope (192.168.20.0) neste servidor;

3ºDefinir a Range de Ips da Scope (de 192.168.20.10 a 192.168.20.199)

4º Definir o Gateway (192.168.20.254)

5º Definir o Servidor de DNS (que neste caso é o mesmo servidor)

Coloquei comentários é só copiar o Texto, colar num notepad e gravar com a extensão *.bat

REM — Batch file para criar uma scope no servidor DHCP
REM — Definir IP estático

@netsh interface ip set address name=”Local Area Connection” static 192.168.20.1 255.255.255.0 192.168.20.254 1
@netsh interface ip set dns “Local Area Connection” static 10.96.54.1
@netsh interface ip set dns “Local Area Connection” static 10.96.54.2
REM — Criar scope 192.168.20.0 no DHCP server 192.168.20.1
@netsh dhcp server 192.168.20.1 add scope 192.168.20.0   255.255.255.0 “Nome da Scope”
REM — Definir address range 192.168.20.10 to 192.168.20.199 para a nova scope
@netsh dhcp server 192.168.20.1 scope 192.168.20.0 add   iprange 192.168.20.10 192.168.20.199
REM — Configurar a Scope option 003 para definir default gateway de 192.168.20.1 para clients
@netsh dhcp server 192.168.20.1 scope 192.168.20.0 set optionvalue 003 IPADDRESS 192.168.20.254
REM — Configurar a Scope option 006 para definir DNS Server de 192.168.20.1 para clients
@netsh dhcp server 192.168.20.1 scope 192.168.20.0 set optionvalue 006 IPADDRESS 192.168.20.1

Observação o @ antes das linhas de código podem sair, coloquei só para não mostrar o comando, é opcional bem como o REM

Share with SociBook.com

Leave a Comment :, , , , more...

Assinatura Outlook com Vbs

by Cláudio Roberto Gonçalves on Dec.02, 2009, under Scripting, Scripts, Tecnologia

Vbs Outlook Signature

Numa organização é sempre bom trabalhar com padrões e quando o fazemos logo desde o inicio facilita muito.

Uma das coisas muito importantes e fixes é a Assinatura. Este Script permite isso, pondo depois com arranque em primeira vez ( procurarei depois explicar como fazer isso) , ajuda a padronizar a Assinatura

é muito importante que os campos na AD estejam preenchidos.

Um Abraço

On Error Resume Next
Set objSysInfo = CreateObject("ADSystemInfo")
strUser = objSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUser)

'DECLARING USER VARIABLES
'-------------------------------------------------
With objUser
	strName = .FullName
	strTitle = .Title
	strOffice = .physicalDeliveryOfficeName
	strCompany = .Company
	strAddress = .streetAddress
	strCountry = .c
	strdivision = .division
	strl = .l
	strco = .co
	strPhone = .TelephoneNumber
	strFax = .facsimileTelephoneNumber
	strMail = .mail
	strWeb = .wWWHomePage
	strExt = .ipPhone
	strAddress3 = .st
'-------------------------------------------------

Set objword = CreateObject("Word.Application")
With objword
	Set objDoc = .Documents.Add()
	Set objSelection = .Selection
	Set objEmailOptions = .EmailOptions
End With

Set objSignatureObject = objEmailOptions.EmailSignature
Set objSignatureEntries = objSignatureObject.EmailSignatureEntries

With objSelection
	.ParagraphFormat.Alignment = wdAlignParagraphRight
	.TypeParagraph
	
	With .Font
		.Name = "Calibri"
		.Size = 12
		.Bold = True
	
	End With
		.TypeText strName & Chr(11)
	With .Font
		.Name = "Calibri"
		.Size = 10
		.Bold = False
		.Italic = False
	
End With
 
.TypeText strTitle & " | " & strOffice & Chr(11)
	.InlineShapes.AddPicture "\\server\public_folder_\logo.jpg"
	.TypeText Chr(11)



With .Font
	.Name = "Calibri"
	.Size = 10
	.Bold = false
End With


.TypeText strAddress & Chr(11) &  & Chr(11) & "Tel: " & strPhone & Chr(11)
.TypeText "Ext: " & strExt & Chr(11)

	'.TypeParagraph


Set objLink = objSelection.Hyperlinks.Add(objSelection.Range, "mailto: " & strMail, , , strMail)
   objLink.Range.Font.Name = "Calibri"
   'objLink.Range.Font.Size = 8
   objLink.Range.Font.Bold = false
.TypeParagraph
Set objLink = objSelection.Hyperlinks.Add(objSelection.Range, "http://www.yoursitehere.com", , , "http://www.yoursitehere.com")& Chr(11)
   objLink.Range.Font.Name = "Calibri"
   'objLink.Range.Font.Size = 8
   objLink.Range.Font.Bold = false
   objSelection.Font.Color = RGB (000,045,154)
	.TypeParagraph

End With

	'.ParagraphFormat.Alignment = wdAlignParagraphRight
	.TypeParagraph
	With objSelection
		With .Font
		.Name = "Calibri"
		.Size = 8
		.Bold = False
		.Color = RGB (000,000,000)
	End With
		.TypeText "This e-mail and any files transmitted contain documentation which is highly confidential and intended solely for the use of the individual or entity to whom they are addressed. All written data and other information in the documentation is and shall remain the property of the disclosing party. If you are not the intended recipient you are hereby formally notified that any disclosure, dissemination, forwarding, storing, copying or use of any of the information is strictly prohibited and will be legally pursued. If you received this in error, please contact the sender and destroy the documentation including deletion of the same from any computer. Thank you."
	End With
End With
Set objSelection = objDoc.Range()
objSignatureEntries.Add "RS_Signature", objSelection
objSignatureObject.NewMessageSignature = "Your_Signature"
objSignatureObject.ReplyMessageSignature = "Your_Signature_Reply"

objDoc.Saved = True
objword.Quit

Share with SociBook.com

Leave a Comment :, , , , , , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!