Desktop_backup.vbs

Print Friendly, PDF & Email
' Login script: Copy All Contents of deferred backup to a Share on Network 
' 
' Author Ishan Karve, 
' Version 1.0 - 1st August 2010 
' Current Version 1.6 - 16 Nov 10 
' 
--------------------------------------------------------------------------- ----------------- 
Option Explicit 
Dim svrPath, deferredPath,pc,compname 
Dim oShell,objFSO,objFolder,msg,username 
Dim folder,subfolder,folderIdx,temp 
Set oShell=CreateObject("WScript.Shell") 
Set objFSO = CreateObject("Scripting.FileSystemObject") 
'get username 
username=oShell.ExpandEnvironmentStrings("%USERNAME%") 
'define server Path 
svrPath="\\xxx.xxx.xxx.xxx\User_Desktop_Backups\" & username & "\desktop_backup\" ' customise to suit requirements 
'define deferred path 
deferredPath=oShell.ExpandEnvironmentStrings("%HOMEPATH%\deferred") 
'Step 1. Check whether deferred folder exists 
If objFSO.FolderExists(deferredPath) Then 
Wscript.Echo "deferred folder exists.Checking Server Status" 
' Step 1.1.1: Check is remote backup server path available 
 If objFSO.FolderExists(svrPath) Then 
        Wscript.Echo "Server Online.Copying Folder" 
 'enumerate local folders 
 Set folder = objFSO.GetFolder(deferredPath) 
 Set subfolder = folder.SubFolders 
 For each folderIdx In subfolder 
                temp=deferredPath & "\" & folderIdx.Name 
 'copy folder to server 
                objFSO.CopyFolder temp ,svrPath 
 'delete local folder 
                objFSO.DeleteFolder(temp) 
 Next 
 'delete deferred folder 
        objFSO.DeleteFolder(deferredPath) 
 Else 
       Wscript.Echo "Server Offline",svrpath 
 End If 
Else 
Wscript.Echo "No deferred folder exists" 
End If 
Ishan Karve

About Ishan Karve

Ishan Karve is just an every day normal guy next door who happens to be an Electronics Engineer by profession and dabbles with PHP, Javascript, C++ and python. His interests vary as seasons change.. they change from astronomy to soul searching. This site is just a reflection of what he does to keep his mind engaged when he is not occupied by work and family. He is an extremely objective guy and is always ready for some good arguments.. of course over a glass of 40% proof alcohol.
This entry was posted in Programming, VB Script and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *