More VBS Scripts for System Administrators Más de scripts de VBS para los administradores de sistemas

Posted on March 30, 2007 at 8:56 am Enviado el 30 de marzo de 2007 a 8:56 horas


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. En los últimos años como un administrador de sistemas, he tenido que escribir un buen número de secuencias de comandos para la gestión de escritorio, la seguridad, y los datos de copia de seguridad. Here are a couple of short scripts that I’ve used in my environment! Aquí tiene un par de breves guiones que he utilizado en mi entorno!

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. Cómo crear un acceso directo en el escritorio - con esta secuencia de comandos, puede obtener una referencia a la destop utilizando la función de carpetas especiales, de modo que no tienen que preocuparse por la ruta exacta para cada usuario. Then just point to a URL or in my case, an internal web server. A continuación, sólo apuntan a una URL o en mi caso, un servidor web interno.

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

strDesktop = WshShell.SpecialFolders(”Desktop”) StrDesktop = WshShell.SpecialFolders ( "Desktop")
set oShellLink = WshShell.CreateShortcut(strDesktop & “\Support Site.URL”) Conjunto oShellLink = WshShell.CreateShortcut (strDesktop & "\ Apoyo 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 Cómo crear una carpeta con los temas en el menú Inicio

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

‘Get the start menu path "Obtener el menú de inicio camino
strStartMenu = WshShell.SpecialFolders(”StartMenu”) StrStartMenu = WshShell.SpecialFolders ( "StartMenu")

‘First delete the old start menu folder - mine is called Apps 'En primer lugar, suprimir la antigua carpeta del menú de inicio de minas se llama Apps
‘ This is the main folder when you click All Programs, then we’ll create 'Esta es la carpeta principal al hacer clic en Todos los programas, entonces vamos a crear
‘ subfolders by dept later on 'Subcarpetas por departamento más tarde
NewFolder = strStartMenu & “\Programs\Apps” NewFolder = strStartMenu & "\ Programs \ Apps"

If FSO.FolderExists( NewFolder ) then Si FSO.FolderExists (NewFolder) entonces
FSO.DeleteFolder NewFolder FSO.DeleteFolder NewFolder
end if Si fin

‘Re-Create or create the folder 'Re - Crear o crear la carpeta

If NOT FSO.FolderExists( NewFolder ) then Si NO FSO.FolderExists (NewFolder) entonces
FSO.CreateFolder NewFolder FSO.CreateFolder NewFolder
End if Fin si

‘Now we create sub-folders for each department 'Ahora creamos subcarpetas para cada departamento
strStartMenu = WshShell.SpecialFolders(”StartMenu”) StrStartMenu = WshShell.SpecialFolders ( "StartMenu")
DeptFolder = strStartMenu & “\Programs\Apps\Dept1″ DeptFolder = strStartMenu & "\ Programs \ Apps \ Dept1"

If NOT FSO.FolderExists( DeptFolder ) then Si NO FSO.FolderExists (DeptFolder) entonces
FSO.CreateFolder DeptFolder FSO.CreateFolder DeptFolder
End if Fin si

‘Work around the short file name problem "Trabajo todo el nombre de archivo corto problema
Dim ret Dim acum
’subst a drive to make the mapping work «Sustancia una campaña para hacer que el trabajo de cartografía
ret = WshShell.Run (”cmd /c subst i: c:\”, 0, TRUE) Acum = WshShell.Run ( "" cmd / C Sustancia yo: c: de ", 0, TRUE)

‘Create the links here, assign shortcut keys, path on server, and working dir "Crear los enlaces aquí, asignar teclas de acceso rápido, la ruta del servidor, y el directorio de trabajo

set oShellLink = WshShell.CreateShortcut(DeptFolder & “\Search Lab Track.lnk”) Conjunto oShellLink = WshShell.CreateShortcut (DeptFolder & "\ Search Lab Track.lnk")
oShellLink.TargetPath = “i:\SearchLab\SearchLab.exe” OShellLink.TargetPath = "c: \ 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 = "c: \ SearchLab \ SearchLab.exe, 0"
oShellLink.Description = “2 - Search Lab Track quickly” OShellLink.Description = "2 - Buscar Lab Track rápidamente"
oShellLink.WorkingDirectory = “i:\SearchLab” OShellLink.WorkingDirectory = "c: \ SearchLab"

‘ You can continue to add more links into the folder, by copying this code above 'Puedes seguir para añadir más enlaces en la carpeta, copiando este código anterior

‘remove the subst 'Eliminar la Sustancia
ret = WshShell.Run (”cmd /c subst i: /d”, 0, TRUE) Acum = WshShell.Run ( "" cmd / C Sustancia yo: / d, ", 0, TRUE)

‘Make sure the start menu is alphatecially ordered "Asegúrese de que el menú de inicio es alphatecially ordenó
‘Deleting from the registry, can’t use regular method. 'Borrado del registro, no pueden utilizar el método ordinario. Must delete by first deleting all subkeys and then deleting key Debe eliminar en primer lugar la supresión de todas las subclaves y de suprimir la clave

strComputer = “.” ‘ use “.” for local computer StrComputer = "." "Utilizar". " Para el equipo 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 = suplantar)! \ \ "& StrComputer &" \ raíz \ defecto: 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 Si Err = 0 Then
For Each strElement In sKeys Por Cada strElement En sKeys
KillKey lHive, strKey & “\” & strElement KillKey lHive, strKey & "\" & strElement
Next Siguiente
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. Cómo permitir que la Encrypt File shorcut en el menú contextual - Esto permitirá a los usuarios hacer clic derecho sobre un archivo y elegir Encriptar, en vez de tener que abrir las propiedades del archivo.

‘ Create an object to hold a reference to the Wscript.Shell object 'Crear un objeto de celebrar una referencia a la 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 "Crear algunas claves del registro y valores utilizando RegWrite con 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. ¿Cómo abrir un documento de Word desde su servidor de archivos automáticamente - Este pequeño guión no hace otra cosa que crear un enlace a una palabra Doc fuera un servidor de archivos y, a continuación, lo abre. You can add some code to maybe open on the file only on Mondays, maybe like a once a week update to the company. Usted puede agregar algo de código abierto para quizás en el expediente sólo los lunes, tal vez como una actualización una vez a la semana a la empresa. Then all you have to do is update the Word file on the server. Entonces todo lo que tiene que hacer es actualizar el archivo de Word en el servidor.

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

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

‘ Get a reference to the Word Application object. "Obtener una referencia a la Palabra objeto Application.
Set appWord = Wscript.CreateObject(”Word.Application”) Set appWord = Wscript.CreateObject ( "Word.Application")
‘ Display the application. 'Mostrar la solicitud.
appWord.Visible = TRUE AppWord.Visible = TRUE

‘ Open ITdocument. 'Open ITdocument.
link = strDesktop & “\Company News.lnk” Enlace = strDesktop & "\ Empresa News.lnk"
appWord.Documents.Open(link) AppWord.Documents.Open (enlace)

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. Cómo eliminar administrador de las acciones de una computadora, lo que incrementa la seguridad siempre y cuando no se esté usando Admin acciones de cualquiera de sus escritorios.

‘ Create an object to hold a reference to the Wscript.Shell object 'Crear un objeto de celebrar una referencia a la 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 "Crear algunas claves del registro y valores utilizando RegWrite con 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 más adelante cuando tengo tiempo!

Related Posts: Related Posts:

Top things Windows System Administrators should and should not do! Inicio de Windows System Administrators cosas deben o no deben hacer!

VBS Script for System Administrators - How to backup Outlook email automatically in a login or logoff script VBS Script para administradores de sistemas - ¿Cómo hacer copia de seguridad de Outlook de correo electrónico automáticamente en una secuencia de comandos de inicio de sesión o desconectarse

If you enjoyed this post, make sure you Si gozan de este puesto, asegúrese subscribe to my RSS feed Suscribirse a mi feed RSS ! !

» Filed Under »Presentadas en virtud del IT Job Stuff IT Empleo Stuff

Related Posts Related Puestos

Please post your comments/suggestions! Por favor enviar sus comentarios o sugerencias!