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脚本系统管理员

Office Ergonomics - Risks of working at a desktop workstation and how to avoid them办公室人体工学-风险的工作,在桌面工作站以及如何避免它们

Gliffy - Online tool to create and share diagrams for free gliffy -在线工具,以创造和分享图免费

Great tool for Help Desk/System Admintrator Professionals - Change Analysis Diagnostic tool伟大的工具服务台/系统admintrator专业人员-变化分析诊断工具

If you enjoyed this post, make sure you 如果你享受这个职位时,要确保你 subscribe to my RSS feed 订阅我的rss饲料 !

» Filed Under »存档下 IT Job Stuff它东西求职

Related Posts相关职位

One Response to “VBS Script for System Administrators - How to backup Outlook email automatically in a login or logoff script”其中一个响应的" vbs脚本为系统管理员-如何备份o utlook电子邮件自动在登录或登出脚本"

  1. Jemas said on : 吉马斯说:

    Like your script, for home user how can I modify it to do a backup to external hard drive on a daily basis.喜欢你的剧本,为家庭用户我怎样才能改变它做一个备份到外部硬盘驱动器上每天都在发生。 Thanks感谢


    Please post your comments/suggestions!请后,你的意见/建议!