VBS Script for System Administrators - How to backup Outlook email automatically in a login or logoff script vbs腳本,為系統管理員-如何備份o utlook電子郵件自動在登錄或登出劇本
Posted on March 13, 2007 at 8:11 am張貼於2007年3月13日在上午8點11分
If you are a Systems Administrator for your company and everyone is using Outlook or some other desktop email program, you’ve probably run into the situation where someone has lost all of their emails due to the fact that it’s saved locally on the user’s computer and not on the main servers.如果你是一個系統管理員為你的公司和每個人都用outlook或其他一些桌面電子郵件程序,你可能會遇到的情況,如果有人失去了他們所有的電子郵件,由於事實,即它的節省了對當地用戶'電腦,並沒有對主服務器。 So if you’re a small shop and can’t afford to get Exchange server, then here’s a simply way to automate the backup of user’s Outlook PST files onto your server in a login or logoff script.所以,如果你是一個小店鋪,並不能得到交換服務器,然後這裡簡單的方式自動備份用戶的outlook pst文件到你的服務器在一個登錄或登出劇本。
First here’s the code and then I’ll explain it:第一次在這裡的收購及合併守則的話,我會作出解釋:
Set shell= WScript.CreateObject(”WScript.Shell”)設空殼= wscript.createobject ( " wscript.shell " )
strUserName = shell.ExpandEnvironmentStrings(”%USERNAME%”) strusername = shell.expandenvironmentstrings ( " %用戶名% " )
Dim fso暗淡的電影服務統籌科
set fso = CreateObject(”Scripting.FileSystemObject”)集電影服務統籌科= createobject ( " scripting.filesystemobject " )
lnDayOfWeek = weekday(now()) lndayofweek =週日(現為( ) )
if lnDayOfWeek = 5 then如果lndayofweek = 5則
If fso.DriveExists(”G:”) Then如果fso.driveexists ( 1 " : " ) ,然後
Dim lcDrive暗淡lcdrive
Set lcDrive = fso.GetDrive(”G:”)定lcdrive = fso.getdrive ( 1 " : " )
If lcDrive.IsReady Then如果lcdrive.isready則
newfolderpath = “\\servername\users\” & strUserName & “\EmailBackup” newfolderpath = " \ \ servername \用戶\ " & strusername & " \ emailbackup "
If Not fso.FolderExists(newfolderpath) Then如果不是fso.folderexists ( newfolderpath ) ,然後
Set newfolder = fso.CreateFolder(newfolderpath)定newfolder = fso.createfolder ( newfolderpath )
End If如果年底
Dim file暗淡檔案
file = “C:\Documents and Settings\” & strUserName & “\Local Settings\Application Data\Microsoft\Outlook\Outlook.pst”檔案=的" c : \文件和設置\ " & strusername & " \地方設置\申請資料\微軟\前台\ outlook.pst "
If fso.FileExists(file) Then如果fso.fileexists (檔案)的話
fso.CopyFile “C:\Documents and Settings\” & strUserName & “\Local Settings\Application Data\Microsoft\Outlook\Outlook.pst”, “\\servername\users\” & strUserName & “\EmailBackup\Outlook.pst” fso.copyfile的" c : \文件和設置\ " & strusername & " \地方設置\申請資料\微軟\前台\ outlook.pst " , " \ \ servername \用戶\ " & strusername & " \ emailbackup \ outlook.pst "
set fso = nothing集電影服務統籌科=無關
wscript.echo “Your email has been backed up!” wscript.echo "你的郵件已後盾" !
end if如果年底
end if如果年底
end If如果年底
end if如果年底
Unforunately, the code is not indented very well here, so you’ll have to copy it and fix it so that you can read it correctly. unforunately ,守則,是不是indented得非常好,所以你需要拷貝和修理,使你可以看它正確。 Basically, it starts off creating a FileSystem object that will take care of copying the file to the server.基本上,它從起飛創建一個文件系統對象會照顧複製該文件到服務器。 Then I do a check to see which day of the week it is and I use 5 (Friday), so that the script only runs once a week.那麼,我做檢查,看看哪日星期幾,它是我用五(週五) ,使該劇本不僅違背了每星期一次。 I also do a check to make sure the G drive is available (the network drive I’m going to be copying the data to) before I get to the copying.我也做了檢查,以確保國道,可(網絡驅動器上,我會被複製的數據) ,然後我得到複製。
Then I check to see if the folder exists that I want to copy to and if not, I go ahead and create that folder in the user’s folder on the server.然後我檢查,看看是否存在文件夾,我想拷貝到,如果沒有的話,我去進取,創建文件夾,在用戶的文件夾在服務器上。 I also check to make sure the file exists and if so, I then copy it to the user’s folder on the network.我還檢查並確認該文件是否存在以及如果是的話,當時我拷貝到用戶的文件夾,就網絡。 I use the shell.ExpandEnvironmentStrings(”%USERNAME%”) method to get the current user’s username.我用shell.expandenvironmentstrings ( " %用戶名% " )的方法,以獲得當前用戶的用戶名。
You can then apply this as either a logon or logoff script using Group Policy!然後你可以申請,這無論是登錄或登出腳本使用組策略!
Related Posts:相關職位:
More VBS Scripts for System Administrators更多vbs腳本系統管理員
Gliffy - Online tool to create and share diagrams for free gliffy -在線工具,以創造和分享圖免費
If you enjoyed this post, make sure you 如果你享受這個職位時,要確保你 subscribe to my RSS feed 訂閱我的rss飼料 ! !
» Filed Under »存檔下 IT Job Stuff它東西求職
Related Posts相關職位
- Is Google really coming out with their own mobile phone?是谷歌真正走出來,用自己的手機嗎?
- Listen to thousands of free Internet radio stations online using TUN3R聽數以千計的免費上網服務,廣播電台網上使用tun3r
- Search for local business listings, maps and directions on your mobile for free搜索本地企業名單,地圖和方向,在你的手機免費
- Website Grader - A free search engine optimization (SEO)/marketing tool網頁年級-免費搜索引擎優化(徐) /行銷工具
- DriveWay - Upload and share multiple large files up to 500 MB each for free車道-上傳與分享多個大型文件多達5 00甲基溴每免費

























Like your script, for home user how can I modify it to do a backup to external hard drive on a daily basis.喜歡你的劇本,為家庭用戶我怎樣才能改變它做一個備份到外部硬盤驅動器上每天都在發生。 Thanks感謝