More VBS Scripts for System Administrators更多vbs脚本系统管理员

Posted on March 30, 2007 at 8:56 am发布于2007年3月30日在上午8点56分

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.在过去的几年里,作为一个系统管理员,我已经写了一些脚本来管理的台式机,安全和数据备份。 Here are a couple of short scripts that I’ve used in my environment!这里是一对夫妇的短脚本我用我的环境!

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. 如何创造一个捷径放在桌面上 -利用这个脚本,你可以得到许多关于d estop利用特殊文件夹功能,使您不必担心确切路径,为每个用户。 Then just point to a URL or in my case, an internal web server.当时刚刚指向一个URL ,或在我的案例中,一个内部网络服务器。

set WshShell = WScript.CreateObject(”WScript.Shell”) 一套wshshell = wscript.createobject ( " wscript.shell " )

strDesktop = WshShell.SpecialFolders(”Desktop”) strdesktop = wshshell.specialfolders ( "桌面" )
set oShellLink = WshShell.CreateShortcut(strDesktop & “\Support Site.URL”)一套oshelllink = wshshell.createshortcut ( strdesktop & " \支持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 如何创建一个文件夹中的项目,在开始菜单

Set FSO = CreateObject(”Scripting.FileSystemObject”) 一套电影服务统筹科= createobject ( " scripting.filesystemobject " )

‘Get the start menu path 『开始菜单路径
strStartMenu = WshShell.SpecialFolders(”StartMenu”) strstartmenu = wshshell.specialfolders ( " [开始] " )

‘First delete the old start menu folder - mine is called Apps '先删除旧的开始菜单文件夹-煤矿是所谓的应用
‘ This is the main folder when you click All Programs, then we’ll create '这是主要的文件夹,当你点击所有程序,那么我们将创造
‘ subfolders by dept later on '子文件夹,由部稍后
NewFolder = strStartMenu & “\Programs\Apps” newfolder = strstartmenu & " \程序\程序"

If FSO.FolderExists( NewFolder ) then如果fso.folderexists ( newfolder ) ,然后
FSO.DeleteFolder NewFolder fso.deletefolder newfolder
end if如果年底

‘Re-Create or create the folder '重新建立或创建该文件夹

If NOT FSO.FolderExists( NewFolder ) then如果不是fso.folderexists ( newfolder ) ,然后
FSO.CreateFolder NewFolder fso.createfolder newfolder
End if如果年底

‘Now we create sub-folders for each department '现在,我们创建子文件夹,为每个部门
strStartMenu = WshShell.SpecialFolders(”StartMenu”) strstartmenu = wshshell.specialfolders ( " [开始] " )
DeptFolder = strStartMenu & “\Programs\Apps\Dept1″ deptfolder = strstartmenu & " \程序\程序\ dept1 "

If NOT FSO.FolderExists( DeptFolder ) then如果不是fso.folderexists ( deptfolder ) ,然后
FSO.CreateFolder DeptFolder fso.createfolder deptfolder
End if如果年底

‘Work around the short file name problem '围绕短期档案名称问题
Dim ret暗淡中RET
’subst a drive to make the mapping work ' subst驱动器,使测绘工作
ret = WshShell.Run (”cmd /c subst i: c:\”, 0, TRUE)中RET = wshshell.run ( " CMD公司/炭subst :在C : \ " , 0 ,属实)

‘Create the links here, assign shortcut keys, path on server, and working dir '创建链接在这里,指派快捷键,路径上的服务器和工作迪尔

set oShellLink = WshShell.CreateShortcut(DeptFolder & “\Search Lab Track.lnk”)一套oshelllink = wshshell.createshortcut ( deptfolder & " \搜索实验室track.lnk " )
oShellLink.TargetPath = “i:\SearchLab\SearchLab.exe” oshelllink.targetpath = "我: \ 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 = "我: \ searchlab \ searchlab.exe , 0 "
oShellLink.Description = “2 - Search Lab Track quickly” oshelllink.description = " 2 -搜索实验室的轨道迅速"
oShellLink.WorkingDirectory = “i:\SearchLab” oshelllink.workingdirectory = "我: \ searchlab "

‘ You can continue to add more links into the folder, by copying this code above '你可以继续添加更多的联系到该文件夹中,复制这上面的代码

‘remove the subst '罢免subst
ret = WshShell.Run (”cmd /c subst i: /d”, 0, TRUE)中RET = wshshell.run ( " CMD公司/炭subst : /文字D " , 0 ,属实)

‘Make sure the start menu is alphatecially ordered '确保开始菜单是alphatecially命令
‘Deleting from the registry, can’t use regular method. '删去,由书记官,不能使用普通的方法。 Must delete by first deleting all subkeys and then deleting key一定要删除,先删去所有subkeys然后删除关键

strComputer = “.” ‘ use “.” for local computer strcomputer = " , " '使用" 。 " ,为本地计算机

Const HKCU = &H80000001 ‘HKEY_CURRENT_USER常量中文大学= & h80000001 ' hkey_current_user

Set objRegistry = GetObject _一套objregistry = getobject _
(”winmgmts:{impersonationLevel=impersonate}!\\” & strComputer & “\root\default:StdRegProv”) ( " winmgmts : ( impersonationlevel =冒充) ! \ \ " & strcomputer & " \根\默认: stdregprov " )

KillKey HKCU, “Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Start Menu” killkey中文大学, "软件\微软\窗户\ CurrentVersion以及\浏览器\ menuorder \开始菜单"

Sub KillKey(lHive, strKey)分killkey ( lhive , strkey )

Dim strElement, IsSubscriptOutOfRange暗淡strelement , issubscriptoutofrange
Dim sKeys()暗淡skeys ( )

objRegistry.EnumKey lHive, strKey, sKeys objregistry.enumkey lhive , strkey , skeys

On Error Resume Next对误差在明年恢复
IsSubscriptOutOfRange = sKeys(0) issubscriptoutofrange = skeys ( 0 )

If Err = 0 Then如果出错= 0 ,然后
For Each strElement In sKeys每个strelement在skeys
KillKey lHive, strKey & “\” & strElement killkey lhive , strkey & " \ " & strelement
Next明年
End If如果年底

Err.Clear err.clear
objRegistry.DeleteKey lHive, strKey objregistry.deletekey lhive , strkey
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. 如何使加密文件shorcut在上下文菜单 -这将允许使用者右击一个文件并选择加密,而不是要公开的特性档案。

‘ Create an object to hold a reference to the Wscript.Shell object '创建一个对象,以持有参考了wscript.shell对象
Dim objShell 暗淡objshell
Set objShell = WScript.CreateObject(”WScript.Shell”) 一套objshell = wscript.createobject ( " wscript.shell " )

‘ Create some registry keys and values using RegWrite with objShell '创造一些注册表项和价值观,用regwrite与objshell
objshell.RegWrite “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\EncryptionContextMenu”, 1, “REG_DWORD” objshell.regwrite " hklm \软件\微软\窗户\ CurrentVersion以及\浏览器\高级\ 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. 如何打开一个Word文件,从你的文件服务器自动 -这个小脚本并不陌生,但创造一个链接到一个W ord文档小康文件服务器,然后打开它。 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.那么,你所需要做的是更新Word文件放在服务器上。

Set FSO = CreateObject(”Scripting.FileSystemObject”) 一套电影服务统筹科= createobject ( " scripting.filesystemobject " )

set WshShell = WScript.CreateObject(”WScript.Shell”)一套wshshell = wscript.createobject ( " wscript.shell " )
strDesktop = WshShell.SpecialFolders(”Desktop”) strdesktop = wshshell.specialfolders ( "桌面" )
set oShellLink = WshShell.CreateShortcut(strDesktop & “\Company News.lnk”)一套oshelllink = wshshell.createshortcut ( strdesktop & " \公司news.lnk " )
oShellLink.TargetPath = “K:\Public\CompanyNews.doc” oshelllink.targetpath =的" K : \公共\ companynews.doc "
oShellLink.Save oshelllink.save

‘ Get a reference to the Word Application object. '得到参考一词的应用对象。
Set appWord = Wscript.CreateObject(”Word.Application”)一套appword = wscript.createobject ( " word.application " )
‘ Display the application. '显示应用。
appWord.Visible = TRUE appword.visible =真实

‘ Open ITdocument. 『开放itdocument 。
link = strDesktop & “\Company News.lnk”链接= strdesktop & " \公司news.lnk "
appWord.Documents.Open(link) appword.documents.open (链接)

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 '创建一个对象,以持有参考了wscript.shell对象
Dim objShell 暗淡objshell
Set objShell = WScript.CreateObject(”WScript.Shell”) 一套objshell = wscript.createobject ( " wscript.shell " )

‘ Create some registry keys and values using RegWrite with objShell '创造一些注册表项和价值观,用regwrite与objshell
objshell.RegWrite “HKLM\SYSTEM\CurrentControlSet\Services\LanManServer\Parameters\AutoShareWks”, 0, “REG_DWORD” objshell.regwrite " hklm \系统\ currentcontrolset \服务\ lanmanserver \参数\ 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!顶部事情Windows系统管理员应该和不应该做些什么!

VBS Script for System Administrators - How to backup Outlook email automatically in a login or logoff script vbs脚本系统管理员-如何备份O utlook电子邮件自动登录或登出剧本

If you enjoyed this post, make sure you 如果你喜欢这个职位,请务必 subscribe to my RSS feed 订阅我的RSS馈送 !

» Filed Under »提起下 IT Job Stuff它的工作内容

Related Posts相关职位

Please post your comments/suggestions!请您评论/建议!