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 ( " startmenu " )

‘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 ( " startmenu " )
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 '創建鏈接,在這裡,指派快捷鍵,路徑上的伺服器,工作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譯文: /日" , 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 const hkcu = & 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 hkcu , "軟件\微軟\窗戶\ 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文檔從你的文件服務器自動 -這個小腳本並不陌生,但創造一個鏈接進入了一個字,文件過的文件服務器,然後打開它。 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!頂部事情視窗系統管理員應該和不應該做些什麼!

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!請後,你的意見/建議!