More VBS Scripts for System Administrators Mais VBS Scripts para administradores de sistema

Posted on March 30, 2007 at 8:56 am Postado em 30 de Março de 2007, 8h56

Over the past few years as a Systems Admin, I’ve had to write a good number of scripts to manage desktops, security, and data backup. Durante os últimos anos como uma Systems Admin, eu tive que escrever um bom número de scripts para gerenciar ambientes de trabalho, segurança, e os dados de backup. Here are a couple of short scripts that I’ve used in my environment! Aqui estão algumas das curto scripts que eu usei no meu ambiente!

How to create a shortcut on the desktop - Using this script, you can get a reference to the destop using the special folders function, so you don’t have to worry about the exact path for each user. Como criar um atalho na área de trabalho - Usando esse script, você pode obter uma referência ao destop usando a função especial pastas, assim que você não terá que se preocupar com o caminho exato para cada usuário. Then just point to a URL or in my case, an internal web server. Então, basta apontar para uma URL ou no meu caso, um servidor web interno.

set WshShell = WScript.CreateObject(”WScript.Shell”) Definir WshShell = WScript.CreateObject ( "WScript.Shell")

strDesktop = WshShell.SpecialFolders(”Desktop”) StrDesktop = WshShell.SpecialFolders ( "Desktop")
set oShellLink = WshShell.CreateShortcut(strDesktop & “\Support Site.URL”) Definir oShellLink = WshShell.CreateShortcut (strDesktop & "\ Suporte Site.URL")
oShellLink.TargetPath = “http://websvr/TechSupport” OShellLink.TargetPath = "http://websvr/TechSupport"
oShellLink.Save OShellLink.Save

How to create a folder with items in the Start Menu Como criar uma pasta com itens no menu Iniciar

Set FSO = CreateObject(”Scripting.FileSystemObject”) Set FSO = CreateObject ( "Scripting.FileSystemObject")

‘Get the start menu path "Obter o menu iniciar caminho
strStartMenu = WshShell.SpecialFolders(”StartMenu”) StrStartMenu = WshShell.SpecialFolders ( "StartMenu")

‘First delete the old start menu folder - mine is called Apps 'First excluir o antigo menu iniciar pasta - mina é chamado Apps
‘ This is the main folder when you click All Programs, then we’ll create 'Esta é a principal pasta quando você clicar em Todos os Programas, em seguida, criaremos
‘ subfolders by dept later on 'Subpastas por Serv posteriormente
NewFolder = strStartMenu & “\Programs\Apps” NewFolder = strStartMenu & "\ Programas \ Apps"

If FSO.FolderExists( NewFolder ) then Se FSO.FolderExists (NewFolder), em seguida,
FSO.DeleteFolder NewFolder FSO.DeleteFolder NewFolder
end if Fim se

‘Re-Create or create the folder 'Re - Criar ou criar a pasta

If NOT FSO.FolderExists( NewFolder ) then Se não FSO.FolderExists (NewFolder), em seguida,
FSO.CreateFolder NewFolder FSO.CreateFolder NewFolder
End if Fim se

‘Now we create sub-folders for each department "Agora nós criar sub - pastas para cada departamento
strStartMenu = WshShell.SpecialFolders(”StartMenu”) StrStartMenu = WshShell.SpecialFolders ( "StartMenu")
DeptFolder = strStartMenu & “\Programs\Apps\Dept1″ DeptFolder = strStartMenu & "\ Programas \ Apps \ Dept1"

If NOT FSO.FolderExists( DeptFolder ) then Se não FSO.FolderExists (DeptFolder), em seguida,
FSO.CreateFolder DeptFolder FSO.CreateFolder DeptFolder
End if Fim se

‘Work around the short file name problem "O trabalho em torno do nome do arquivo de curto problema
Dim ret Dim Ret
’subst a drive to make the mapping work "Substância uma unidade para fazer o mapeamento trabalho
ret = WshShell.Run (”cmd /c subst i: c:\”, 0, TRUE) R = WshShell.Run ( "cmd / c Substância eu: c: \", 0, TRUE)

‘Create the links here, assign shortcut keys, path on server, and working dir 'Criar os links aqui, atribuir teclas de atalho, caminho no servidor, e trabalhando Dir.

set oShellLink = WshShell.CreateShortcut(DeptFolder & “\Search Lab Track.lnk”) Definir oShellLink = WshShell.CreateShortcut (DeptFolder & "\ Search Lab Track.lnk")
oShellLink.TargetPath = “i:\SearchLab\SearchLab.exe” OShellLink.TargetPath = 'i: \ SearchLab \ SearchLab.exe "
oShellLink.WindowStyle = 1 OShellLink.WindowStyle = 1
oShellLink.Hotkey = “CTRL+SHIFT+S” OShellLink.Hotkey = "CTRL + SHIFT + S"
oShellLink.IconLocation = “i:\SearchLab\SearchLab.exe, 0″ OShellLink.IconLocation = 'i: \ SearchLab \ SearchLab.exe, 0 "
oShellLink.Description = “2 - Search Lab Track quickly” OShellLink.Description = "2 - Lab Search Track rapidamente"
oShellLink.WorkingDirectory = “i:\SearchLab” OShellLink.WorkingDirectory = 'i: \ SearchLab "

‘ You can continue to add more links into the folder, by copying this code above "Você pode continuar a adicionar mais links para a pasta, por copiar este código acima

‘remove the subst "Remover o Substância
ret = WshShell.Run (”cmd /c subst i: /d”, 0, TRUE) R = WshShell.Run ( "cmd / c Substância eu: / d ', 0, TRUE)

‘Make sure the start menu is alphatecially ordered "Certifique - se de iniciar o menu é alphatecially ordenados
‘Deleting from the registry, can’t use regular method. "Deleting do registro, não pode utilizar regularmente método. Must delete by first deleting all subkeys and then deleting key Deve excluir pela primeira suprimindo todas subchaves e, em seguida, apagando - chave

strComputer = “.” ‘ use “.” for local computer StrComputer = "." Utilização "." Para o computador local

Const HKCU = &H80000001 ‘HKEY_CURRENT_USER Const HKCU = & H80000001 'HKEY_CURRENT_USER

Set objRegistry = GetObject _ Set objRegistry = GetObject _
(”winmgmts:{impersonationLevel=impersonate}!\\” & strComputer & “\root\default:StdRegProv”) ( "Winmgmts: (impersonationLevel = fingir)! \ \" & StrComputer & "\ raiz \ padrão: StdRegProv")

KillKey HKCU, “Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Start Menu” KillKey HKCU, "Software \ Microsoft \ Windows \ CurrentVersion \ Explorer \ MenuOrder \ Start Menu"

Sub KillKey(lHive, strKey) Sub KillKey (lHive, strKey)

Dim strElement, IsSubscriptOutOfRange Dim strElement, IsSubscriptOutOfRange
Dim sKeys() Dim sKeys ()

objRegistry.EnumKey lHive, strKey, sKeys ObjRegistry.EnumKey lHive, strKey, sKeys

On Error Resume Next On Error Resume Next
IsSubscriptOutOfRange = sKeys(0) IsSubscriptOutOfRange = sKeys (0)

If Err = 0 Then If Err = 0 Then
For Each strElement In sKeys Para Cada strElement Em sKeys
KillKey lHive, strKey & “\” & strElement KillKey lHive, strKey & "\" & strElement
Next Próxima
End If End If

Err.Clear
objRegistry.DeleteKey lHive, strKey ObjRegistry.DeleteKey lHive, strKey
End Sub End Sub

How to enable the Encrypt File shorcut in the context menu - This will allow a user to right click on a file and choose Encrypt, rather than having to open the properties of the file. Como ativar o Encrypt File shorcut no menu de contexto - Isso permitirá que um usuário clique direito sobre um arquivo e Encrypt escolher, em vez de ter que abrir as propriedades do arquivo.

‘ Create an object to hold a reference to the Wscript.Shell object 'Criar um objeto para manter uma referência ao Wscript.Shell objeto
Dim objShell Dim objShell
Set objShell = WScript.CreateObject(”WScript.Shell”) Set objShell = WScript.CreateObject ( "WScript.Shell")

‘ Create some registry keys and values using RegWrite with objShell 'Criar uma secretaria chaves e valores usando RegWrite com objShell
objshell.RegWrite “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\EncryptionContextMenu”, 1, “REG_DWORD” Objshell.RegWrite "HKLM \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Explorer \ Advanced \ EncryptionContextMenu", 1, "REG_DWORD"

How to open a Word document from your file server automatically - This little script does nothing but create a link to a Word Doc off the file server and then opens it. Como abrir um documento do Word o seu arquivo servidor automaticamente Trata - pouco o script não faz nada, mas criar um link para um arquivo do Word Doc fora servidor e, em seguida, abre - lo. You can add some code to maybe open on the file only on Mondays, maybe like a once a week update to the company. Você pode adicionar alguns códigos para talvez aberto sobre o arquivo só na segunda - feira, talvez como uma atualização uma vez por semana para a empresa. Then all you have to do is update the Word file on the server. Então tudo que você tem a fazer é atualizar o arquivo Word no servidor.

Set FSO = CreateObject(”Scripting.FileSystemObject”) Set FSO = CreateObject ( "Scripting.FileSystemObject")

set WshShell = WScript.CreateObject(”WScript.Shell”) Definir WshShell = WScript.CreateObject ( "WScript.Shell")
strDesktop = WshShell.SpecialFolders(”Desktop”) StrDesktop = WshShell.SpecialFolders ( "Desktop")
set oShellLink = WshShell.CreateShortcut(strDesktop & “\Company News.lnk”) Definir oShellLink = WshShell.CreateShortcut (strDesktop & "\ Company News.lnk")
oShellLink.TargetPath = “K:\Public\CompanyNews.doc” OShellLink.TargetPath = "K: \ Public \ CompanyNews.doc"
oShellLink.Save OShellLink.Save

‘ Get a reference to the Word Application object. "Obter uma referência para o Word Application objeto.
Set appWord = Wscript.CreateObject(”Word.Application”) Set appWord = Wscript.CreateObject ( "Word.Application")
‘ Display the application. "Mostra o pedido.
appWord.Visible = TRUE AppWord.Visible = TRUE

‘ Open ITdocument. 'Open ITdocument.
link = strDesktop & “\Company News.lnk” Ligação = strDesktop & "\ Company News.lnk"
appWord.Documents.Open(link) AppWord.Documents.Open (ligação)

How to remove admin shares from a computer - This greatly increases security as long as you’re not using Admin shares on any of your desktops. Como administrador para remover partes de um computador - Isso aumenta muito segurança enquanto você não está usando Admin partes em qualquer um dos seus ambientes de trabalho.

‘ Create an object to hold a reference to the Wscript.Shell object 'Criar um objeto para manter uma referência ao Wscript.Shell objeto
Dim objShell Dim objShell
Set objShell = WScript.CreateObject(”WScript.Shell”) Set objShell = WScript.CreateObject ( "WScript.Shell")

‘ Create some registry keys and values using RegWrite with objShell 'Criar uma secretaria chaves e valores usando RegWrite com objShell
objshell.RegWrite “HKLM\SYSTEM\CurrentControlSet\Services\LanManServer\Parameters\AutoShareWks”, 0, “REG_DWORD” Objshell.RegWrite "HKLM \ SYSTEM \ CurrentControlSet \ Services \ LanManServer \ Parameters \ AutoShareWks", 0, "REG_DWORD"

I’ll post some more later on when I have time! I'll post alguns mais tarde, quando eu tiver tempo!

Related Posts: Related Posts:

Top things Windows System Administrators should and should not do! Top coisas Windows System Administrators deve e não deve fazer!

VBS Script for System Administrators - How to backup Outlook email automatically in a login or logoff script VBS Script para System Administrators - Como fazer um backup Outlook e - mail automaticamente em um login ou sessão scripts

If you enjoyed this post, make sure you Caso você tenha este cargo, certifique - se de subscribe to my RSS feed Inscrever - se em meu feed RSS ! !

» Filed Under »Filed Under IT Job Stuff IT Job Stuff

Related Posts Related Posts

Please post your comments/suggestions! Please postar seus comentários e sugestões!