Plus de manuscrits de VBS pour des interfaces gestionnaire

Signalé le 30 mars 2007 chez 8:56 AM

Au cours de ces dernières années en tant que les systèmes Admin, j'ai dû écrire un bon nombre de manuscrits pour contrôler des ordinateurs de bureau, la sécurité, et la protection de données. Voici un couple des manuscrits courts que j'ai employés dans mon environnement !

Comment créer un raccourci sur l'ordinateur de bureau - En utilisant ce manuscrit, vous pouvez obtenir une référence au destop en utilisant la fonction spéciale de chemises, ainsi vous ne devez pas s'inquiéter du chemin exact pour chaque utilisateur. Puis point juste à un URL ou dans mon cas, un web server interne.

placez WshShell = WScript.CreateObject ( » WScript.Shell »)

strDesktop = WshShell.SpecialFolders ( » ordinateur de bureau »)
placez l'oShellLink = le WshShell.CreateShortcut (strDesktop et « \ appui Site.URL »)
oShellLink.TargetPath = « http://websvr/TechSupport »
oShellLink.Save

Comment créer une chemise avec des articles dans le menu de début

Placez FSO = CreateObject ( » Scripting.FileSystemObject »)

Le `obtiennent le chemin de menu de début
strStartMenu = WshShell.SpecialFolders ( » StartMenu »)

Le `suppriment d'abord la vieille chemise de menu de début - la mine s'appelle Apps
Le `que c'est la chemise principale quand vous cliquez tous les programmes, alors nous créera
subfolders de `par département plus tard
NewFolder = strStartMenu et « \ programmes \ Apps »

Si FSO.FolderExists (NewFolder) puis
FSO.DeleteFolder NewFolder
finissez si

Le `recréent ou créent la chemise

Sinon FSO.FolderExists (NewFolder) puis
FSO.CreateFolder NewFolder
Finissez si

`Maintenant nous créons des secondaire-chemises pour chaque département
strStartMenu = WshShell.SpecialFolders ( » StartMenu »)
DeptFolder = strStartMenu et « \ programmes \ Apps \ Dept1 ″

Sinon FSO.FolderExists (DeptFolder) puis
FSO.CreateFolder DeptFolder
Finissez si

Travail de `autour du problème court de nom de fichier
Faible rouissez
' subst une commande pour faire le travail traçant
rouissez = WshShell.Run ( » subst i de /c de cmd : c:\ », 0, VRAIS)

Le `créent les liens ici, assignent les clefs de raccourci, le chemin sur le serveur, et le dir fonctionnant

placez l'oShellLink = le WshShell.CreateShortcut (DeptFolder et « \ laboratoire Track.lnk de recherche »)
oShellLink.TargetPath = « i:\SearchLab\SearchLab.exe »
oShellLink.WindowStyle = 1
oShellLink.Hotkey = « CTRL+SHIFT+S »
oShellLink.IconLocation = « i:\SearchLab\SearchLab.exe, 0 ″
oShellLink.Description = « 2 - recherchez la voie de laboratoire rapidement »
oShellLink.WorkingDirectory = « i:\SearchLab »

`Que vous pouvez continuer pour ajouter plus de liens dans la chemise, en copiant ce code ci-dessus

le `enlèvent le subst
rouissez = WshShell.Run ( » subst i de /c de cmd : /d », 0, VRAIS)

Le `s'assurent que le menu de début est alphatecially commandé
Le `supprimant de l'enregistrement, ne peut pas employer la méthode régulière. Doit supprimer en supprimant d'abord tous les subkeys et touche alors d'effacement

strComputer = « . » utilisation de `« . » pour l'ordinateur local

Const HKCU = &H80000001 `HKEY_CURRENT_USER

objRegistry réglé = GetObject _
( » winmgmts : {impersonationLevel=impersonate} ! \ \ » et strComputer et « \ racine \ défaut : StdRegProv »)

KillKey HKCU, « logiciel \ Microsoft \ Windows \ CurrentVersion \ explorateur \ MenuOrder \ menu de début »

KillKey secondaire (lHive, strKey)

Faible strElement, IsSubscriptOutOfRange
Faibles sKeys ()

objRegistry.EnumKey lHive, strKey, sKeys

Sur le résumé d'erreur après
IsSubscriptOutOfRange = sKeys (0)

Si errent = 0 alors
Pour chaque strElement dans les sKeys
KillKey lHive, strKey et « \ » et strElement
Après
Finissez si

Err.Clear
objRegistry.DeleteKey lHive, strKey
Sous-marin d'extrémité

Comment permettre le shorcut de dossier de chiffrage dans le menu de contexte - Ceci permettra un utilisateur au bon clic sur un dossier et choisir chiffrez, plutôt qu'en devez ouvrir les propriétés du dossier.

‘ Create an object to hold a reference to the Wscript.Shell object
Dim objShell
Set objShell = WScript.CreateObject(”WScript.Shell”)

‘ Create some registry keys and values using RegWrite with objShell
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. You can add some code to maybe open on the file only on Mondays, maybe like a once a week update to the company. Then all you have to do is update the Word file on the server.

Set FSO = CreateObject(”Scripting.FileSystemObject”)

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

‘ Get a reference to the Word Application object.
Set appWord = Wscript.CreateObject(”Word.Application”)
‘ Display the application.
appWord.Visible = TRUE

‘ Open ITdocument.
link = strDesktop & “\Company News.lnk”
appWord.Documents.Open(link)

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.

‘ Create an object to hold a reference to the Wscript.Shell object
Dim objShell
Set objShell = WScript.CreateObject(”WScript.Shell”)

‘ Create some registry keys and values using RegWrite with objShell
objshell.RegWrite “HKLM\SYSTEM\CurrentControlSet\Services\LanManServer\Parameters\AutoShareWks”, 0, “REG_DWORD”

I’ll post some more later on when I have time!

Related Posts:

Top things Windows System Administrators should and should not do!

VBS Script for System Administrators - How to backup Outlook email automatically in a login or logoff script

If you enjoyed this post, make sure you subscribe to my RSS feed!

» Filed Under IT Job Stuff

Related Posts

Please post your comments/suggestions!